Terraform Uses in AWS.

Arpita Srivastava
4 min readJul 28, 2020

Using Terraform code to create the Infrastructure on AWS and deploy a small web application on to it.

It may seem lengthy process but once the code is done everything will be done in just one click.

Before we start let just understand some basic about Terraform.

What is Terraform?

Terraform is an open-source infrastructure as code software tool created by HashiCorp. It enables users to define and provision a datacenter infrastructure using a high-level configuration language known as Hashicorp Configuration Language, or optionally JSON.

Advantages of Terraform.

  • Super portability — you have one tool and one language for describing infrastructure for Google cloud, AWS, OpenStack and ANY other cloud. Switching a provider is not a headache anymore.
  • Ease of full-stack deployment — you can have Amazon instances running Kubernetes containers with your workloads, and manage the whole system from one tool.


  • Create the private key and store it in your local system.
  • Create VPC with a Public Subnet, Internet Gateway, Route Table and its association.
  • Assign Auto IP.
  • Create a Security Group. (Allow SSH, HTTP)
  • Create a EC2 Instance (Do ssh and Install httpd, git, php, efs-utils, nfs-utils).
  • Create EFS(Elastic File System) and mount it to the /var/www/html.
  • Create the S3 Bucket and store the image in it.
  • Create a Cloud Front Distribution.

All of these will be done with just one click. And finally using your EC2 IP or DNS server name run it in your browser.

I have attached GitHub repository url where you find the Terraform code and the Website code. I am showing how this will happen:

Step 1: Create the key- hybrid1

Step 2: Create the VPC- HybridCloud.

Step 3: Create the Subnet- Public_Subnet.

Step 4: Create the Route Table- Route Table.

Step 5: Create Internet Gateway- MyIG.

Step 6: Create the Security Group- sgtask2.

Step 7: Create the EC2 instance- Task2.

Step 8- Create the EFS.

Step 9- Create the S3 Bucket- hybrid-cloud-1.

Step 10- Put the image in your S3 bucket- vimalDaga.jpg.

Step 11- Create the Cloud Front Distributions.

Step 12- Enter the EC2 IP or DNS name on your browser.

Follow these steps:

Yupppp that’s it to make all this happen. You just have to make some changes to the code according to your credentials and the path of the file.

Thanks for reading. Hope this will help you. If you find it useful please give some claps. See you soon.