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

In my previous two blogs I have explained this whole project bit by bit but I have used the ebs volume in that part. Their is some limitations of using ebs volumes we cant use them in different subnets and also we cant mount them on multiple pods at the same time. However to overcome this limitation we can use EFS storage which provides a centralized storage and also can be mounted on multiple pods at same time.

Now I will explain the part which I have changed in the previous projects.

First I have written a terraform code for the security group in which the traffic for NFS server can pass.

Now I have written the code for creating the file system.

After creating the server we need to provide it the mount target and the details for the security group as well as the subnet ids.

Here you can give multiple subnet ids by creating a variable also or simply you can copy them from the cloud.

Now after creating the EFS system we are going to launch the instances and will give volume tags in it.

While working on the ebs volume we need to first create the volume than we need to attach it and after that we need to create the partitions and than mount a new folder in it. But here we dont have to do that much of work we just need to mount the pre created file system to the desired folder. And also to make the mount permanent I have created an entry in the fstab directory.

As you can see the efs storage is mounted to the desired folder and after the mount git clone is used to store the data permanently in this.

This is the part I have changed in my previous code so as to use efs storage instead of an ebs volume.

If you didnt understand anything in it I would recommend you to read my previous blogs first. All the code is in my git repo.


Github URL:- https://github.com/akshat-crypto/HCC_TASK2.git

Previous Blog:- https://medium.com/@akshatsoni396/launching-an-app-server-using-terraform-f1c95c778c8f

LinkedIN Profile:- https://www.linkedin.com/in/akshat-soni-011b461a6/




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Create a cheap http-proxy on GCP with terraform ( tutorial )

5 Reasons Why Ionic Remains to be the Top Choice for App Development

Ever shipped a pet project to production?

Exploring Firebase Authentication on iOS

Consumer Driven Contract (CDC) Test with Pact.io, Javascript and Go (Javascript part)

Hello World!!! of Kubernetes [Part 2]

Set up a Django project (Python-based web framework)

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
Akshat Soni

Akshat Soni

More from Medium

Platonic heartbreak: the pain of losing a friend is very real

Veganism in Pakistan

Pride and when it’s shaken