Creating Webserver in AWS cloud using Terraform
Amazon Web Services(AWS)
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
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:-
- First we download terraform(https://www.terraform.io/).
- Create a file in notepad.
Step 2:- Now, configure your AWS profile.
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.
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.
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.
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.
Step 7:- Then attach this EBS volume.
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.
Step 9:- Put object in this bucket.
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.
Step 11:- Use null_resource.
It is used for implementing the standard resource lifecycle but takes no further action.
Step 12:- Now go to command window and download terraform plugins and init.
Now, you can finally launch the instance with terraform apply command.
Thank you.