Launching website using AWS EC2 instance and Amazon EFS

Hey there! Here we are going to launch a website on an EC2-instance and to make the storage persistent we will use Amazon EFS. But we’ll do all this using terraform code. In case you want to use Amazon EBS then you can check this out.

Before we begin, we need to set-up the provider in terraform. You can find that step here. So, let’s start now.

Step1: Create a Security Group

Step2: Create a EFS File System and Mount Targets

Step 3: Launching Instance and mounting EFS to that Instance

Step 4: Cloning the Source Code

That code contains the dynamic content for which we’ll not use Cloudfront Service. Now we’ll create an S3 bucket and put the static content of the website in that bucket. Then we’ll create CloudFront distribution for the static content of the website and we’ll replace the URL of the image with the URL from the CloudFront for the image using sed command. And luckily all this is exactly same what we did while using EBS with Instance. So head on to that article, using https://medium.com/@me_kabhi/creating-complete-infrastructure-on-aws-using-terraform-d660f1fe007f.

That’s all for this story. Thanks for stopping by. Until next time!

You can find the complete code at:

Let’s connect over Linkedin: