Launch Application using Terraform using EFS service on the AWS.

Vanshita Mittal
4 min readAug 21, 2020

Finally, I completed Task 2 of Hybrid Multi Cloud under the mentorship of Vimal Daga Sir .

Terraform :

Terraform is an open-source infrastructure as code, software tool created by HashiCorp. It enables users to define and provision data center infrastructure using a declarative configuration language known as HashiCorp Configuration Language (HCL), or optionally JSON.

Elastic File System (Amazon EFS) :

It is a cloud storage service provided by Amazon Web Services (AWS) designed to provide scalable, elastic, concurrent with some restrictions, and encrypted file storage for use with both AWS cloud services and on-premises resources.

TASK :

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

STEPS :

  1. First you need to login into aws by user account .You can use root account but for security user account is better with restrictions can be done.
aws configure --profile user_name

Push the html code and image to Github .

2. Login to aws account

provider "aws" {
region = "ap-south-1"
profile = "profile-name"
}

3. Creating Key-pair :

4. Creating Security Groups which support port 80 and 22.

5. Launching Instance :

6. Creating EFS :

resource "aws_efs_file_system" "myefs"{   
creation_token="my-efs"
tags = {
Name= "myefs"
}
}
resource "aws_efs_mount_target" "first" {
file_system_id = aws_efs_file_system.myefs.id
subnet_id = "subnet-880c0fe0"
security_groups= [aws_security_group.sc-1.id]
}

7. Creating S3 bucket:

8. Creating CloudFront :

9. Initialize the terraform to download plugins ….

aws portal before apply the code …

10. Now, to run above code , use …

terraform apply

then …..

Instances …..

Security Group….

EFS….

S3 bucket ….

CloudFront…

11. To see webpage use instance ip :

12. After all , don’t forget to destroy all these using …

Finally , Task is successfully completed !!!

Thank You !

--

--

No responses yet