HYBRID-MULTI-CLOUD (TASK-2)

MAYANK VARSHNEY
3 min readSep 2, 2020

--

Using EFS service with Terraform.

Objective:

Perform the task-1 using EFS instead of EBS service on the AWS as,
Create/launch Application using Terraform

1. Create Security group which allow 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. 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

This demonstration is a tweak in previous setup of Infrastructure as a code with AWS & Terraform , refer to this post:

Link: https://www.linkedin.com/posts/mayank-varshney-62744a163_task1-awscloud-terraform-activity-6679009553696264192-Is5h

In this above post, we’ve created an infrastructure with a web server, configured on EC2 service with S3 and Cloud Front service providing static file provider with CDN capability, and Giving the block storage with EBS service of AWS.

In this demonstration, we’re going to replace storage from EBS(elastic block storage) to EFS(elastic file system) .

As EFS works as a NFS server and is a managed service by AWS. Need to do the persistence in web server as we might need to scale in or out dynamically, and since EBS is block storage and can be attached to one system only, so we need to use a centralized system for storage, which is provided by NFS, either we can setup our own NFS server or we can use EFS as managed NFS service.

Let’s first create Security group for EFS :

Here, at first creation of EFS, and then we create mount target. Here I created mount target in Mumbai region (ap-south-1a). Before mount target we need to create a VPC , and subnet for Mount targets in EFS.

Now we can easily mount these target to Web server machine as:

Finally completed !!

Link to code : https://github.com/mayank-aly/cloud-task-2.git

--

--

MAYANK VARSHNEY

I am a forward-thinking individual with exceptional skills in problem-solving, adaptive thinking, automation, and development.