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
LinkedIN Profile:- https://www.linkedin.com/in/akshat-soni-011b461a6/