Launching a Website using Elastic File Services in AWS

Launching a Website using Elastic File Services in AWS

Amazon Web Services (AWS) is a secure cloud services platform, offering compute power, database storage, content delivery and other functionality to help businesses scale and grow. Running web and application servers in the cloud to host dynamic websites. Hence this proves to be the best way to provide IAAS (Infrastructure As A Service).

In this article we will see how to launch a website using various services like EC2 (Elastic Cloud Compute) ,EFS (Elastic File Services) ,S3 (Simple Storage Service) and Cloudfront.

We will first create a key and a security group which will be attached to an EC2 instance. Next we will install all the necessary frontend softwares inside it like HTTPD ,PHP ,Github and efs-utils. Then we will create an EFS volume which will attached to the instance and mounted on the folder /var/www/html. This folder contains the code for our website which is also downloaded from Github. After this we create the S3 bucket and upload the image downloaded from the Github and then create a Cloudfront Distribution of the bucket.

Lets get started with the complete process

  • Downloading the necessary plugins for the provider - We run the terraform init command to initialize the environment and download the necessary plugins of the provider.
No alt text provided for this image
No alt text provided for this image
  • Generating the new keypair - We then generate a keypair inorder to attach it to the instance and we also download the pem file of the keypair in the same folder.
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
  • The downloaded key is in the folder.
No alt text provided for this image
  • Creating a Security Group for Instance - We create a new Security Group for instance which allows SSH ,HTTP and EFS as the ingress rule inorder to have connectivity to the outside world and also to the EFS volume because the EFS volume can be accessed across availability zones hence we need to establish a connection with it too.
No alt text provided for this image
No alt text provided for this image
  • Launching a new instance - Now we finally launch a new instance the above security group inside which we will download the necessary softwares.
No alt text provided for this image
No alt text provided for this image
  • Installing necessary softwares - Now we attach the remote provisioner to access the EC2 instance through SSH using the key downloaded in the folder and then we install the HTTP AND GIT softwares. In addition to this we also install efs-utils. The amazon-efs-utils package comes with a mount helper and tooling that makes it easier to perform encryption of data in transit for Amazon EFS. A mount helper is a program that you use when you mount a specific type of file system. Hence we use the mount helper included in amazon-efs-utils to mount our Amazon EFS file systems.
No alt text provided for this image
No alt text provided for this image
  • Creating an EFS volume - Next we will create a new EFS volume which depends on the creation of the instance.
No alt text provided for this image
No alt text provided for this image
  • Attaching the EFS volume to the Instance - Next this volume will be mounted on the instance in which we have our website running this requires the file system id of the EFS created , the security group and subnet id of the instance which we have previously launched.
No alt text provided for this image
  • Downloading the code from Github and mounting the volume to the instance - We will now download the code of our website from the Github directly inside the /var/www/html folder and mount the EFS volume to the same folder.
No alt text provided for this image
  • Creating S3 Bucket - Now we create a S3 bucket in which we will upload the static content of our website. It has public-read permissions to allow the objects inside it to be accessed over internet in readable form. Hence giving it public access.


No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
  • Uploading the image in S3 - The static content of the website is an image which will be uploaded to the bucket so that the storage requirements are not high enough.
No alt text provided for this image
No alt text provided for this image
  • Creating Cloudfront Distribution - Finally we create a Cloudfront Distribution of the S3 bucket so that it can be easily accessed over internet without any latency.
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

Terraform Validate command to check for any errors in the code.

No alt text provided for this image

Terraform Apply command to automatically create the complete infrastructure in just one click.

No alt text provided for this image

It will create all the resources.

No alt text provided for this image
No alt text provided for this image

Download all the necessary requirements and the softwares.

No alt text provided for this image

And finally launch the website.

No alt text provided for this image


要查看或添加评论,请登录

Mansi Gautam的更多文章

社区洞察

其他会员也浏览了