- Always make sure to destroy your API Service. Forgetting to do so could incur a large AWS fee
- Never commit your AWS Account ID to git. Save it in an
.envfile and ensure.envis added to your.gitiginore
Add an .env file containing your AWS account ID and region. Example file:
AWS_ACCOUNT_ID=1234567890
AWS_REGION=ap-southeast-1
Create a backend.tf file and add it to both /infra/setup/backend.tf and /infra/app/backend.tf. Example files:
terraform {
backend "s3" {
region = "<AWS_REGION>"
bucket = "<BUCKET_NAME>"
key = "<APP_NAME>/terraform.tfstate"
}
}
terraform {
backend "s3" {
region = "<AWS_REGION>"
bucket = "<BUCKET_NAME>"
key = "<APP_NAME>/terraform.tfstate"
}
}
Alternatively you can skip this step to store your Terraform state locally.
All of the following commands are run via the Makefile.
- Setup your ECR Repository (one time)
make setup-ecr
- Build and deploy your container
make deploy-container
- Deploy your API Service on ECS Fargate
Note: The URL for your endpoint will be printed by Terraform once the above command is done executing. Example:
make deploy-servicealb_dns_name = "<APP_NAME>-alb-123456789.<AWS_REGION>.elb.amazonaws.com". Navigate to that URL in your browser to ensure the API is working. You can also check out the API docs at the<URL>/docsendpoint.
- Destroy your API Service on ECS Fargate
make destroy-service