AWS INFRA CREATION WITH PYTHON
DJANGO APP DEPLOYMENT [LOCAL]
Step1 - Clone the repository and set the aws
configure in local terminal
l
https://github.com/praveen1994dec/Terrafor
lo
m_withcontainers.git
x.
Step2 - Create a repo in aws ECR with name
- > django-app
le
ip
.a
w
Step3 - Once the repo is created copy the
w
repo url and add it in the variables.tf file in
place of variable docker_image_url_django
w
Get more free courses at www.aiplex.lol
l
lo
Step4 - Change the policy file paths in iam.tf
and variables.tf file
x.
le
ip
.a
Step5 - Login into ECR by hitting the below
command in terminal local
w
aws ecr get-login-password --region
w
us-west-1 | docker login --username AWS
--password-stdin <YOUR ECR REPO URL>
w
Step6 - Go to app folder
cd app/
Get more free courses at www.aiplex.lol
Step7 - Build the docker image
docker build --platform=linux/amd64 -t <URL
ECR REPO URL>:latest .
l
lo
Step8 - Push the image to ECR
x.
docker push <URL ECR REPO URL>:latest
le
Step9 - Go to terraform folder and hit this
ip
below command to create the key pair
.a
ssh-keygen -f california-region-key-pair
Step10 - Add the above file key file path in
w
variable.tf
w
w
Get more free courses at www.aiplex.lol
Step 11 - Hit the below commands in
terraform folder
terraform init
terraform plan -out terraform.out
l
terraform apply "terraform.out"
lo
Step12 - Install Python BOTO3
pip install boto3 click
x.
Step13 - Export the AWS access/Secret key and
region le
export AWS_ACCESS_KEY_ID=""
ip
export AWS_SECRET_ACCESS_KEY=""
export AWS_DEFAULT_REGION="us-west-1"
.a
Step14 - Go to deploy folder
python3 update-ecs.py --cluster=production-cluster
w
--service=production-service
Step15 - Validate the ECS service and there should
be 0 Tasks pending in the dashboard
w
w
Go to cloudwatch/VPC and check the data and logs
stream
Get more free courses at www.aiplex.lol
Step16 - > Go to EC2-> Loadbanacer -> Copy the
DNS name -> Hit the below url in the browser
<DNS_NAME>/ping/
l
lo
Step17 - Hit the command and delete the
architecture
x.
terraform destroy
le
ip
.a
w
w
w
Get more free courses at www.aiplex.lol