- AWS CLI is installed
- Terraform AWS provider:
- The
default
AWS configuration profile is used - AWS Region is
us-west-2
- The
- The solution will use the default VPC and sub-nets.
- Step into the
ecr
folder - Deploy infrastructure
terraform init
terraform plan
terraform apply --auto-approve
- Navigate to ECR in the AWS Console - https://us-west-2.console.aws.amazon.com/ecr/private-registry/repositories?region=us-west-2
- Select the
ecs-primary
Repository - Click
View push commands
button - Complete the steps to build/tag/push to the ECR repository.
- Select the
- Authenticate Docker client
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin AWS_ACCOUNT.dkr.ecr.us-west-2.amazonaws.com
- Build the Docker image:
docker build -t ecs-primary .
- Tag Docker image for push to ECR
docker tag ecs-primary:latest AWS_ACCOUNT.dkr.ecr.us-west-2.amazonaws.com/ecs-primary:latest
- Push to ECR
docker push AWS_ACCOUNT.dkr.ecr.us-west-2.amazonaws.com/ecs-primary:latest
- Confirm the image exists in the
- Step into the
ecs-service-web
folder - Update Task definition
- Navigate to
task-definition.json
- Update the
"image"
value toAWS_ACCOUNT.dkr.ecr.us-west-2.amazonaws.com/ecs-primary:latest
- Navigate to
- Update ALB ingress whitelist IP
- Navigate to
vars.tf
- Update the
default
value forwhitelist_cidr_block
- Your IP -
YOUR.IP.GOES.HERE/32
- Public -
0.0.0.0/0
- Your IP -
- Navigate to
- Deploy infrastructure
terraform init
terraform plan
terraform apply --auto-approve
- Copy Outputs value for
alb_dns
- Paste the
alb_dns
value into a browser and enjoy!
- Step into the
ecs-service-web
folder - Destroy infrastructure
terraform destroy --auto-approve
- Step into the
ecr
folder - Destroy infrastructure
- Navigate to ECR in the AWS Console
- Click the
ecs-primary
repository - Delete the
latest
image- This is required, otherwise a
RepositoryNotEmptyException:
is returned by Terraform
- This is required, otherwise a
terraform destroy --auto-approve