Automation On AWS by Using Terraform

by:- SHIVANGI SAXENA

How can we set up an Infrasture of AWS by using Terraform?

What is Terrafrom ?

Terraform Cloud is a free to use SaaS application that provides the best workflow for writing and building infrastructure as code with Terraform. Share infrastructure as code Empower your team to rapidly review, comment, and iterate on Infrastructure as Code.

Task Synopsis

1. Create the 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. A developer has uploaded 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.



Steps :-

  1. Create a IAM account in AWS and Download the Credentials file.
  2. In windows or on your base system cmd run this command.
  3.  Give your credentials(your access key and seGive provider in aws because we want to automate aws and profile you created in lasr steps.10. Now , We will create a security Group,and allow http and ssh proctocol
    Note: http port number is 80 and ssh port number is 22cret key)
  4. Create a file where terraform.exe is present and make another directory aand a notepad file with extension .tf (you can create different file for each resource/part or can code in one file also).
  5.  Now , We will create a security Group,and allow http and ssh protocol
  6.  
  7. Note: HTTP port number is 80 and the ssh port number is 22.
  8. Now We create an EC2 instance.
  9. In the above screenshot, he has used the connection to connect this instance with the key, and provisioner to remotely execute the command on our instance.
  10. Now we create an EBS Volume and attach this to EC2.
  11. Getting a remote connection.
  12. In the above screenshot, we have mounted the partition remotely using the provisioner and clone the GitHub repo with the /var/ww/html/ directory.
  13. Creating a S3 bucket -
  14. S3 bucket policy to make bucket publically accessible
  15. S3 bucket object -
  16. Cloudfront creation
  17. Create an IAM policy 
  18. Now run the terraform apply command
  19. Now we can access the code on git hub repositories by accessing the IP of my instance.
  20. Now Access the cloudfront domain name and the image name as http://dregqk6l9jwyb.cloudfront.net/myimage.jpg . then we can download that image stored on s3 bucket.

Comments

Popular posts from this blog

EKS Training at LinuxWorld Information Pvt Ltd.