Deployment of Application on AWS using Terraform (EFS service)

Suraj Jadhav
4 min readAug 23, 2020

EFS (Elastic File System)

Why we’re using EFS service instead of EBS volume?

It is possible to mount the EFS volume with multiple instances. And also, we can mount the EFS volume with the instances, which are in different availability zones. So using EBS we can’t achieve this kind of feature.

Before going through this article, I suggest you to visit my previous article on “Deployment of Application on AWS using Terraform (EBS service)”, there I’ve given an explanation of each step except EFS.

Previous article link

Let’s start……

Configure the AWS provider

Creating New Key Pair for EC2 instances

Creating New Security group for EC2 instances

Creating New Security group for EFS service

For now, I’m allowing all inbound and outbound traffic, but for security purpose you can set a specific inbound and outbound rules as per requirement.

Launching EC2 instance in subnet (ap-south-1a)

Launching EC2 instance in subnet (ap-south-1b)

Creating EFS File System

Adding Mount Target : subnet (ap-south-1a)

Adding Mount Target : subnet (ap-south-1b)

Mounting the EFS file system to the instance (ap-south-1a)

Mounting the EFS file system to the instance which is in the subnet (ap-south-1a) at location /var/www/html/. And downloading the code from the github at same location.

Mounting the EFS file system to the instance (ap-south-1b)

Same EFS file system is mounting to the instance, which is available in different subnet or availability zone.

Creating S3 Bucket

Download GitHub Repository to local-system

Upload Images to S3 bucket

Creating CloudFront

Update CloudFront Link

Execution of Terraform file

Given below is the terraform command to execute this file. After successfully executed we can see the total no. of resources added in the AWS.

Successfully executed
Key Pair
Security Groups
Instances
EFS file system
Mounted Targets
S3 Bucket
Uploaded Image in S3 Bucket
Cloud Front

Testing Web Application

Accessing Web Application using Public IP of instance which is launched in subnet (ap-south-1a)
Accessing Web Application using Public IP of instance which is launched in subnet (ap-south-1b)

Conclusion

Accessing same web application, working on different web servers (diffferent instances) which are in different availability zones using EFS service of AWS.

Thanks for reading till the end…

Suggestions are greatly appreciated…

--

--

No responses yet