SIMULTANEOUS CHANGE - EFS
Task-2
Create/launch Application using Terraform.
1. Create a Security group that allows the port 80.
2. Launch EC2 instance.
3. In this EC2 instance use the existing key or provided key and security group which we have created in step 1.
4. Launch one Volume using the EFS service and attach it in your VPC, then mount that volume into /var/www/html.
5. The developer has uploaded the code into GitHub repo and 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
ABBREVIATIONS USED —
AWS — Amazon Web Service
EC2 — Elastic Compute Cloud
EFS — Elastic File System
S3 — Simple Storage Service
IaaS — Infrastructure as a service
PaaS — Platform as a service
SaaS — Software as a service
EBS - Elastic Block Storage
NOTE -
Before starting check the environment variables that the path is given for:
OpenSSH
AWS
Terraform
Git
AWS — Amazon Web services is a Public Cloud that provides IaaS, PaaS, and SaaS services.
TERRAFORM — Terraform is created by HashiCorp.It is an open-source infrastructure as a code service. It has its own language known as HashiCorp Configuration Language. Terraform is used to make an application that is integrated with multiple clouds(like AWS, Azure, Openstack, etc). It provides Standardisation.Terraform file extension is “file_name.tf”.
LOGIN TO AWS IAM ACCOUNT THROUGH CMD -
COMMAND- “ aws configure — profile iam_user_name ”
IAM user is used for the security purpose means when you share your code with others then no need to give access key and secret key.
TERRAFORM CODE -
VARIABLE SYNTAX -
variable “unique_name1” {
default = “name”
}
OUTPUT SYNTAX-
output “unique_name1” {
value = resource_name.unique_name
}
CREATE KEY IN AWS -
PUBLIC KEY — It is seen by everyone just like a lock is seen by everyone.
PRIVATE KEY — It is like a key that unlocks a lock and this key is with only the owner means the owner is the one who can open the lock.
The private key is used to make a connection with the instance so that only the owner can access the instance.
declare variables
Provide the service provider name
Create key-pair
Here “variable, provider and resource ” are keywords and “aws_key_pair” is a resource name, and “enter_key_name” is a unique name.
OUTPUT -
The key is created.
SECURITY GROUPS -
It is like a firewall that allows those IPs which are allowed by the admin. It sets inbound and outbound rules which means who can access it and whom he can access. So this security group is used by EC2 instances and EFS Volume. Port 80 is used for HTTP and port 22 is used for SSH. Port 443 is used for TLS/SSL.
OUTPUT -
A security group is created.
Here see that ingress/egress is given.
I have used default VPC.
These are default subnets.
EC2 INSTANCE-
It is made by AMI means amazon provides some images which can be used directly and launched within minutes.
According to my requirements, I have configured it by using a remote provisioner.
OUTPUT-
The instance is created.
The volume is attached to the ec2 instance and is in use now. This volume is created by default when the instance is launched.
The NIC card is attached to the instance.
COPY IP IN FILE-
Copied IP in the file which will be saved in the local directory.
EFS -
EFS is a Regional Service that provides high availability and durability. When we launch multiple instances we attach EBS to each but when it the time to change something in the files but it’s difficult to change simultaneously each Block Storage so here comes the concept of EFS which is attached to instances a file changed in one instance will change in other also here we give one path in EFS so any change in that path will be applied to every instance attached to it.
OUTPUT-
EFS is created.
See its metered size and other services present there.
We can monitor the usage also.
DOWNLOAD IMAGES FROM GITHUB TO LOCAL SYSTEM-
Local Provisioner will help to download images from the GitHub.
These are the files that will be downloaded by this code.
S3 -
S3 is an Object Storage where we can upload the images, videos, etc and its link can be used in the code.
OUTPUT-
S3 is created.
Image is present here and it is publicly accessible.
CLOUDFRONT -
Cloudfront is a Content Delivery Network that works on the motive of low latency. It is used because when we use any application we need faster access to images, videos, etc.
So what does it do?
AWS has Mumbai as a region but I am far away from Mumbai and want faster access so AWS created CDN so every time when you access things it will be fetched from the nearby location with low latency.
In the last lines of code, I have used a local provisioner so it will automatically open the webpage on the chrome and eliminate my manual work.
OUTPUT-
CloudFront is Created.
Some details about CloudFront.
Monitor what you did?
Finally, the webpage is launched automatically.
Let’s go inside the instance and see whether our GitHub files are present there or not. As we can see it is present.
TERRAFORM -
Terraform excludes our manual work and its single command launches everything and also removes everything.it provides the help command where we can see which commands can we use.
TERRAFORM COMMANDS —
Go inside the folder where the terraform file is saved and install the plugins that are required by the command “terraform init”.
2. Terraform provides a validate command which validates the terraform files.
3. “terraform plan” command is a very useful command because launching the services you can check your code working.
4. “terraform apply” command is used to run the services.
Here while running the code you can see our code doing the same as we said to it.
Cloning the github code in /var/www/html .
5. If you want to run the services then run the command “terraform apply” and if you want to terraform do not ask for yes or no then run “terraform apply --auto-approve”.
Cloudfront is creating.
Finally open Chrome automatically.
6. If you want to destroy the services you applied the run command “terraform destroy” and if you want terraform do not ask for yes or no then run “terraform destroy -auto-approve”.
TERRAFORM COMMANDS -
“terraform init” -> install the required plugins and initialize the terraform.
“terraform apply” -> run the program
“terraform destroy” -> delete all the things that are running.
“terraform apply --auto-approve” -> run the program without asking yes/no.
“terraform destroy --auto-approve” -> delete all the things that are running without asking yes/no.
THANK YOU FOR READING.
Github URL - https://github.com/manali1230/EFS.git
Comments
Post a Comment