control ec2 is a server automation to control a python server deployed on lambda function using api gateway
The following is required:
- Terraform v1.2.2
- GoLang v1.18.3
These enviroment variables are required:
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
terraform init
terraform apply --auto-approve
cd test && go test -v -timeout 3000s infra_test.go
terraform destroy --auto-approve
Terraform script will do the following:
- Create ec2 instance with default tags (You can change it from
variables.tf
) - Create s3 bucket with python server
- Deploy python server on lambda function
- Create two api gateway endpoints to communicate with lambda
/stop
will stop ec2 instance
/tags
will get ec2 tags
On every push for main and develop will trigger test-infra
it will run the test (Will be locked only for main)
Environment variables are hooked up as secrets like the following:
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}