The code in the root of this IAC directory will create a Fargate ECS cluster, RDS Postres db, ALB, and other supporting resources. This code depends on resources created in the account_setup01 and account_setup02 directories to run.
- Latest version of Terraform
- aws cli tools installed and configured with an AWS profile that has privileges to create all of the Terraform resources
- Docker installed and running. ie.
docker ps
command should work.
- Open this directory in a terminal.
- Ensure the aws profile you want to use is active and works with the us-east-2 region without passing any additional parameters.
- Running
aws sts get-caller-identity
should work properly without any additional parameters.
The code in this root IAC folder depends on the Terraform being run in account_setup01 and account_setup02 first.
- Open terminal in account_setup01 folder
terraform init -var 'bucket_name=myuniquebucketname' -var 'app_name=myapp' -out setup01.plan
- Review the plan and run the next step when ready to create the resources.
terraform apply setup01.plan
For additional details, see account_setup01/README.md.
- Open terminal in account_setup02 folder
terraform init -var 'app_name=myapp' -out setup02.plan
- Review the plan and run the next step when ready to create the resources.
terraform apply setup02.plan
For additional details, see account_setup02/README.md.
The Terraform code you ran in the account_setup02 folder created a file named docker_build_push.sh
in the root folder of this git repository.
- Open terminal in the root of this git repository
./docker_build_push.sh
This will take a while, but you should see at the end, a docker image being pushed to ECR.
Finally.... this is the IAC you were looking for. :) This creates a application load balancer, security groups, and an ECS cluster running the app.
FIRST: Open the terraform.tfvars in your favorite editor. Update the app_name
, ecr_image_tag
, and alb_allowed_list
.
- Open terminal in this iac directory.
terraform init
terraform apply
- Review the plan output and type 'yes' when ready.
This will take a while, but should finish successfully.
You'll find a test.http file in the root of this repository that can be used to easily test the Bunny REST API within VSCode if you have the REST Client extension installed.
- open the test.http file.
- You'll need to change the @baseUrl variable to point to the load balancer you just created. You'll find the load balancer dns name near the end of the
terraform apply
output... or...
# If you're on a mac
terraform output -json | jq -r '.baseurl.value' | pbcopy
and paste the value for @baseUrl
Finally... click on send request in the file in the different sections to send different requests. The response should show in a separate window on the right side.