[go: up one dir, main page]

0% found this document useful (0 votes)
6 views5 pages

M - Withcontainers - Git: Docker - Image - Url - Django

This document outlines the steps for creating AWS infrastructure and deploying a Django application using Python and Docker. It includes instructions for cloning a repository, creating an AWS ECR repo, building and pushing a Docker image, and deploying the application using Terraform. Additionally, it covers validating the ECS service and cleaning up resources after deployment.

Uploaded by

vinay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views5 pages

M - Withcontainers - Git: Docker - Image - Url - Django

This document outlines the steps for creating AWS infrastructure and deploying a Django application using Python and Docker. It includes instructions for cloning a repository, creating an AWS ECR repo, building and pushing a Docker image, and deploying the application using Terraform. Additionally, it covers validating the ECS service and cleaning up resources after deployment.

Uploaded by

vinay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

AWS INFRA CREATION WITH PYTHON

DJANGO APP DEPLOYMENT [LOCAL]

Step1 - Clone the repository and set the aws


configure in local terminal
https://github.com/praveen1994dec/Terrafor
m_withcontainers.git

Step2 - Create a repo in aws ECR with name


- > django-app

Step3 - Once the repo is created copy the


repo url and add it in the variables.tf file in
place of variable docker_image_url_django
Step4 - Change the policy file paths in iam.tf
and variables.tf file

Step5 - Login into ECR by hitting the below


command in terminal local

aws ecr get-login-password --region


us-west-1 | docker login --username AWS
--password-stdin <YOUR ECR REPO URL>

Step6 - Go to app folder


cd app/
Step7 - Build the docker image

docker build --platform=linux/amd64 -t <URL


ECR REPO URL>:latest .

Step8 - Push the image to ECR

docker push <URL ECR REPO URL>:latest

Step9 - Go to terraform folder and hit this


below command to create the key pair

ssh-keygen -f california-region-key-pair

Step10 - Add the above file key file path in


variable.tf
Step 11 - Hit the below commands in
terraform folder
terraform init

terraform plan -out terraform.out

terraform apply "terraform.out"

Step12 - Install Python BOTO3


pip install boto3 click

Step13 - Export the AWS access/Secret key and


region
export AWS_ACCESS_KEY_ID=""

export AWS_SECRET_ACCESS_KEY=""

export AWS_DEFAULT_REGION="us-west-1"

Step14 - Go to deploy folder


python3 update-ecs.py --cluster=production-cluster
--service=production-service

Step15 - Validate the ECS service and there should


be 0 Tasks pending in the dashboard

Go to cloudwatch/VPC and check the data and logs


stream
Step16 - > Go to EC2-> Loadbanacer -> Copy the
DNS name -> Hit the below url in the browser

<DNS_NAME>/ping/

Step17 - Hit the command and delete the


architecture
terraform destroy

You might also like