Creating Webserver in AWS cloud using Terraform

Creating Webserver in AWS cloud using Terraform

Amazon Web Services(AWS)

No alt text provided for this image


Amazon Web Services (AWS) is the world’s most comprehensive and broadly adopted cloud platform, offering over 175 fully featured services from data centers globally. Millions of customers—including the fastest-growing startups, largest enterprises, and leading government agencies—are using AWS to lower costs, become more agile, and innovate faster.

Terraform

No alt text provided for this image

Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions. Configuration files describe to terraform  the components needed to run a single application or your entire datacenter.

Project 1: To create and launch an application using Terraform

1) Create the key and security group which allow 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.

Step 1:-

No alt text provided for this image
  • Create a file in notepad.
No alt text provided for this image

Step 2:- Now, configure your AWS profile.

No alt text provided for this image

Step 3:- Now we create a Key pair using Putty.

Key pair is combination of two keys i.e, public and private key. we need a key pair to connect ti the instances.

No alt text provided for this image
No alt text provided for this image

Step 4:- Now we create a security group that allows SSH and HTTP to acces.

Security group will act like a firewall. it will control the incoming and outgoing traffic for your instances.

No alt text provided for this image

Step 5:- Now we create an EC2 instance.

An EC2 instance is a virtual server in amazon's elastic compute cloud for running applications on AWS. It provides different instance types to enable you to choose CPU, memory,storage and networking capacity that one must need to run an application.

No alt text provided for this image

Step 6:- Then create EBS volume.

This service provides a range of options that allow you to optimize storage performance and cost for your workload.

No alt text provided for this image

Step 7:- Then attach this EBS volume.

No alt text provided for this image

Step 8:- Create S3 bucket.

It is a public cloud storage resource which is available in AWS's Simple Storage Service. We can store objects here.

No alt text provided for this image

Step 9:- Put object in this bucket.

No alt text provided for this image

Step 10:- attaching cloudfront with S3

Amazon cloudfront is a CDN that delivers data, videos, applications and APIs to customers globally. It has low latency, high security and high speed.

No alt text provided for this image
No alt text provided for this image

Step 11:- Use null_resource.

It is used for implementing the standard resource lifecycle but takes no further action.

No alt text provided for this image

Step 12:- Now go to command window and download terraform plugins and init.

No alt text provided for this image

Now, you can finally launch the instance with terraform apply command.

No alt text provided for this image


Thank you.


To view or add a comment, sign in

More articles by Dhwani Vora

Others also viewed

Explore content categories