- Install terraform v1.5.2
- Setup the aws cli credentials with
default
profile name.
- Apply the
remote_state
terraform project. This will create s3 bucket and lock table for keeping remote state for other tf projects.
cd infra/accounts/dev/remote_state; terraform init; terraform apply
- Apply the
ecs
terraform project.
cd infra/accounts/dev/ecs; terraform init; terraform apply
This will output
- URL to access the web server.
- ECR repo url where docker images should be pushed.
- Make desired code changes to
src
directory. - Run docker build
cd src; docker build -t <docker_ecr_repo_url>:<version> .
- Docker login into the ECR repo
aws ecr get-login-password --region <region> | docker login --username AWS --password-stdin <ecr_repo_url>
- Publish docker image
docker push <docker_ecr_repo_url>:<version>
- Apply the
ecs
terraform project with the version provided in above step
cd infra/accounts/dev/ecs; terraform apply -var="release_version=<release_version>"
- Use EC2 rather than fargate to reduce infra cost
- Use terragrunt for making terraform code DRY in case new env is added.