Integration of AWS with Terraform Using GitHub.

Problem Statement

1. Create the key and security group which allows 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. The 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 an 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

step1:-

Here we make the security key which further helps us in login into the AWS EC2 instance. And also save one key.pem file in your system which contains your private key.

step2

Here we create the security group (Firewall) with the inbound rule of HTTP which helps us to retrieve the web page.

step3

Here we create the AWS instance which launches OS in the cloud. And install software which requires to launch our web page/website.

step4

Here we create the EBS volume of size 1GBi. And launch in the same availability zone where our OS is present.

step5

Here we attach the EBS volume into our OS. And for attaching any disk we need to format 1st then mount it into our desire location.

step6

Now we create the Bucket which contains our image. Here this image is downloaded from GitHub automatically by the terraform and save it into the local system.

step7

Here the downloaded image is uploaded into the bucket from your local system.

step8

Now we create the Cloud front which helps to content delivery without any latency. and it creates the local cache so that client did not needs to come again and again to the availability zone. It directly accesses through there near edge location.

step9

Here we create the null resource which edits the code and inserts the image URL into the webpage automatically.

“echo -n \”<img src=’http://${aws_cloudfront_distribution.s3_distribution.domain_name}/${aws_s3_bucket_object.object.key}'>\" >> /var/www/html/index.php”,

step10

For executing the code use terraform init command in the cmd it will download all the necessary plugin into your system.

Now use terraform apply -auto-approve to apply.

If you want to check your Terraform code is valid or not use terraform validate cmd.

B.Tech student and Researcher. Like To Study And Publish Article Related To New Technologies.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store