LAUNCH AN APPLICATION ON AWS 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

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 the Security Group which allow the port 80.

4. Launch EC2 instance by using the key and security key created.

5. EBS volume with size 1GB.

6. After creating the EBS volume now we need to mount it with the instance and then download the code from the github into the folder /var/www/html

7. Now I have created a S3 bucket and with permission to public and their i have downloaded the image from github.

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

9. Here I had 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.

Here is my website launched on aws using terraform.

Here is the github link of my code.

Thank you!

--

--

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 💻