This project provisions an AWS EC2 instance using Terraform and configures Apache APISIX on it using Ansible. It also includes a GitHub Actions pipeline for full CI/CD automation.
flowchart TD
A[Developer Pushes to GitHub] --> B[GitHub Actions CI/CD]
B --> C[Terraform: Provision EC2 + Security Group]
C --> D[Terraform Outputs EC2 Public IPs]
D --> E[Shell Script: Generate Ansible Inventory]
E --> F[Ansible Playbook: Install Apache APISIX]
F --> G[EC2 Instance: Apache APISIX Running]
G --> H[Client Requests to APISIX]
subgraph Local Option
A2[Developer Runs Terraform Manually]
A2 --> C
D --> E2[Run Inventory Script Locally]
E2 --> F2[Run Ansible Locally]
F2 --> G
end
Install:
- Clone the repo and navigate to the folder
- Run Terraform
- Generate inventory with
scripts/update_inventory.sh - Run
scripts/trigger_ansible.sh
- Visit:
http://<EC2_PUBLIC_IP>:9080 - Create a route via curl:
curl -X PUT http://<EC2_PUBLIC_IP>:9080/apisix/admin/routes/1 \ -H "X-API-KEY: edd1c9f034335f136f87ad84b625c8f1" \ -d '{"uri":"/demo","upstream":{"type":"roundrobin","nodes":{"httpbin.org:80":1}}}' - Access it at:
http://<EC2_PUBLIC_IP>:9080/demo
cd terraform
terraform destroy -auto-approve-
Terraform provisions the environment on AWS (VPC, EC2, security groups, etc.).
-
Ansible configures Apache APISIX and supporting tools on provisioned EC2 instances.
-
Apache APISIX serves as a production-ready API Gateway that routes traffic securely to your microservices.