This repository builds and deploys a simple application using Terraform to deploy the infrastructure, Docker to build the image, and AWS Elastic Beanstalk to run the container.
- Elastic Bean Stalk (ECS) to run containers.
- Elastic Container Registry (ECR), repository to store docker images.
- Terraform Backends, to save states in the cloud.
- AWS Permissions with role, policies and profile.
- AWS S3 Bucket to store terraform states and others files.
-
How to create Docker images for a Django project.
-
AWS Role, Policy and Profile with Terraform to assign permissions to BeanStalk to manage containers.
-
Run applications with Elastic Beanstalk through Terraform:
-
Deploy the application version into Elastic Beanstalk.
-
Put docker image on Elastic Beanstalk Repository (ECR).
-
Create Dockerrun.aws.json to run a Beanstalk application.
-
Create, configure and add files to a AWS S3 Bucket through the Terraform.
- Go to
cd ./env/prod
- Check
terraform plan
- Deploy
terraform apply
Web Interface:
http://<elasticbeanstalk_dns>:80
-
Build new image
cd ./api docker build -t [AWS_ACCOUNT_ID].dkr.ecr.[REGION].amazonaws.com/production:v1 .
-
Push image to ECR
docker push [AWS_ACCOUNT_ID].dkr.ecr.[REGION].amazonaws.com/production:v1 aws ecr get-login-password --region [REGION] | docker login --username AWS --password-stdin [AWS_ACCOUNT_ID].dkr.ecr.[REGION].amazonaws.com
-
ZIP Dockerfilerun.aws.json
zip -r production.zip Dockerrun.aws.json
-
Deploy with Terraform
terraform init terraform apply
-
Update application version
aws elasticbeanstalk update-environment --environment production-environment --version-label production