This task is about launching an application on AWS using services like EC2, EFS, S3 and Cloudfront with the help of terraform.

Task Description :

1. Create Security group which allow the port 80.

2. Launch EC2 instance.

3. In this Ec2 instance use the existing key or provided key and security group which we have created in step 1.

4. Launch one Volume using the EFS service and attach it in your vpc, then mount that volume into /var/www/html

5. Developer have uploded the code into github repo also the repo has some images.

6. Copy the github repo code into /var/www/html

7. Create S3 bucket, and copy/deploy the images from github repo into the s3 bucket and change the permission to public readable.

8 Create a Cloudfront using s3 bucket(which contains images) and use the Cloudfront URL to update in code in /var/www/html

Terraform Code :

  1. Here we are using aws as provider so we need to setup region and profile.

2. Create the key pair.

3. Create VPC, Subnet and Internet Gateway.

4. Create Route Table.

5. Creating Security Group.

6. Launch EC2 Instance.

7. Create EFS Volume.

8. Mount the EFS to /var/www/html.

9. Created a S3 bucket and with permission to public and their downloaded the image from github.

10. Created a Cloudfront using s3 bucket and then I use the Cloudfront URL to update in code in /var/www/html

11. Printed the IP of the instance and also launched the application using chrome after the whole setup is ready.

Now I just need to run the terraform command to run the code.

terraform apply -auto-approve

Here is the final output of my code.

VPC, Subnet and Internet Gateway :

Route Table :

Security Group :

EC2 Instance :

S3 Bucket :

Cloudfront :

Thank You!!




I'm passionate learner diving into the concepts of computing 💻

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

An Attempt at Rhino: Class Assignment 9

A simple and clean way to monkey-patch your apps — Django

Photo by Edgar, snippet made in @carbon_app

HTTP/2 for noobs, by a noob

665: The First Steps

Log Aggregation: A Brief Guide

How Scraping NBA Stats is cooler than Michael Jordan

Migration Issues: redirect www to non-www with GoDaddy, Azure and SSL

Get Inference from SageMaker

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aditya Raj

Aditya Raj

I'm passionate learner diving into the concepts of computing 💻

More from Medium

How to Create Custom EC2 VPCs in AWS Using Terraform

Automated Static Site Deployment in AWS Using Terraform

VITE : Website using AWS, Terraform and CircleCI

Create AWS EKS with AWS Cloudformation — Step By Step