Using AWS Services with Terraform

“Core Services used for this automated environment”

What is Terraform ?

Use Infrastructure as Code to provision and manage any cloud, infrastructure, or service. Terraform users define infrastructure in a simple, human-readable configuration language called HCL (HashiCorp Configuration Language). Users can write unique HCL configuration files or borrow existing templates from the public module registry.

In this post, I will be describing about Integrated environment for Webserver on AWS platform using Terraform.

Highlights of the AWS’s services used in this small project :

  1. EFS (Elastic File System) — For giving persistent(permanent) storage to our instance’s folder “/var/www/html”
  2. S3 Storage — For uploading a image into the bucket which will be displayed on the webpage.
  3. CloudFront Distributions — This is used for providing CDN (Content Delivery Network) for our webpage for faster loading of our webpage.
AWS Management Console
Services
Iam page
  • Create the user and copy this access key and security access key as it will be shown only once.
See Access key and security access key
aws configure

Let’s start with terraform code :

  1. Initially, we have to write “provider” in starting of the code.
AWS Provider
Key Pair Creation
Default VPC and Subnet
These screenshots are pasted here because these are exported variables and these can be used to assign values in our code
Deployment is creating
EC2 Dashboard
EC2 Instance
Webserver file -> “index.php”
S3 Bucket
Object in the S3 bucket
EFS Volume

Now, all the resources are created and we have added the CloudFront URL in our webpage, so we can see the output :

  1. OUTPUT FROM CLOUDFRONT URL
Cloudfront URL displays the object
You can see my webserver is running

I am a student and persuing under graduation in computer science and engineering.