Task 1 : How to create/launch Application using Terraform

Nithish Kumar
4 min readJun 15, 2020

--

Terraform

Steps to launch App using terraform …

1.Create the key and security group which allow the port 80.
2. Launch EC2 instance.
3. In this Ec2 instance use the key and security group which we have created in step 1.
4. Launch one Volume (EBS) and 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

Solution :

Step 1: create the key and security group which allow the port 80.

→Creating the key pair from aws cloud … Click on create key pair and then download the key for login purpose ….

creating key pair

→Now creating security group for allowing SSH and HTTP protocol… It will allows SSH and HTTP protocol

code for Security group..

Step 2 & 3: Launch EC2 Instance .. In this use the key and security group which we have created in step 1.

→Code for Launching instance using terraform …

Step 4: Launch one Volume (EBS) and mount that volume into /var/www/html

→ Launch EBS insame region where EC2 instance launched with size of 1 GiB …and then attach to EC2 instance

EBS volume attached to EC2 Instance …

→For mounting the volume , we need connection to EC2 instance … After connecting to EC2 instance , we need to mount the volume , so that we have one function called “ remote-exec ” … Here is the code …

Here ‘ sudo git clone ‘ command used for copying the pages from github.com,, So we done with Step 6 …

Step 5: GitHub account has the webpage …Here is my GitHub account and i have uploaded the index.html file

Github link…

Step 7: Create S3 bucket, and copy/deploy the images from github repo into the s3 bucket and change the permission to public readable. And also I am uploading the image from my base system …

S3 Bucket ..

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

→ Creating Cloud front …

Cloud front created …

→ copy Cloud front url and paste into the .html file …

Url pasted …

Now run the command “ terraform apply — auto-approve ” in the folder where u have written the code with .tf extension …

Now type the IP address of EC2 Instance .. In my case it is 35.154.49.191..

Output is ::

my Html page …

Finally , Done with the task step by step …
My github url is https://github.com/KumarNithish12/cloud-task-1.git Go through this link for code ..

…. Signing off ….

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Nithish Kumar
Nithish Kumar

Written by Nithish Kumar

Aspiring DevOps/Cloud Engineer. #Believe in you.

No responses yet

Write a response