AWS automation using Terraform and Jenkins
First lets know about the basic terminologies used in this project .
What is Cloud Computing?
Cloud computing is a term referred to storing and accessing data over the internet. It doesn't store any data on the hard disk of your personal computer. In cloud computing, you can access data from a remote server.
What is AWS?
Amazon web service is a platform that offers flexible, reliable, scalable, easy-to-use and cost-effective cloud computing solutions.
AWS is a comprehensive, easy to use computing platform offered Amazon. The platform is developed with a combination of infrastructure as a service (IaaS), platform as a service (PaaS) and packaged software as a service (SaaS) offerings.
Important AWS Services
Amazon Web Services offers a wide range of different business purpose global cloud-based products. The products include storage, databases, analytics, networking, mobile, development tools, enterprise applications, with a pay-as-you-go pricing model.
What is Terraform?
Terraform is an open-source infrastructure as a code software tool created by HashiCorp. It enables users to define and provision a datacenter infrastructure using a high-level configuration language known as Hashicorp Configuration Language (HCL).
Task : Have to create/launch Application using Terraform
- Create the key and security group which allow the port 80.
- Launch EC2 instance.
- In this Ec2 instance use the key and security group which we have created in step 1.
- Launch one Volume (EBS) and mount that volume into /var/www/html
- Developer have uploded the code into github repo also the repo has some images.
- Copy the github repo code into /var/www/html
- Create S3 bucket, and copy/deploy the images from github repo into the s3 bucket and change the permission to public readable.
- Create a Cloudfront using s3 bucket(which contains images) and use the Cloudfront URL to update in code in /var/www/html
Solution:
We will do all the process step by step. So let's start.
Step1:
Creating two folders which contains two terraform file each having their own used cases
Seeing the content of the two folders.
Step2:
Configuring AWS terraform profile :
You can create your profile using aws configure. [ $ aws configure –profile profile_name ]
Step3:
Creating S3 Bucket :
Now for uploading the image to s3 bucket we have to clone it from the Github into our local system and then we have to give it's path . So for this we have use Jenkins.
Step4:
Downloading object/image in S3 bucket
Step5:
Creating Cloudfront :
Step6:
Now once we get the url of the image in s3 bucket we manually go to our web page file and provide it in the image source column
Step7:
Now we switch to our next terraform file which we will use for instance creation. Configuring AWS terraform profile once again to create instances :
Step8:
Creating Key :
Step9:
Creating Security Group :
This security group will allow port 80 and 22.
Step10:
Creating AWS Instance :
This will connect via ssh and install the following softwares in it.
Step11:
Creating EBS Volume :
This volume will act as a persistent storage
Step12:
Attaching,Creating partition, formatting and mounting EBS Volume to Instance :
Final Output:
This is all from my side. Hope you like my work. Any suugestions or improvements related to this task is always appreciated.
Link to my Github profile :
https://github.com/stushar12/cloud_task1
Associate @JP Morgan Chase and Co. | CIB Technology
4 年Inspiring
SDE @Freecharge (A subsidiary of Axis Bank) | Ex- TCS | FinTech
4 年Great work bro.