[Recipes] Amazon EFS with Amazon EC2

Problem: 

Use EFS to share data across two EC2 instances.

Solution Summary: 

Create two instances of EC2, each in two different AZs. Mount EFS and demo data sharing.

Solution Steps: 

  1. Go to AWS console and go to EFS.

  2. In the create file system wizard, you need to specify as VPC (can leave as the default one). Leave the IP address selection to Automatic.

  3. Subnets for each AZ and security groups for the selected VPC will be automatically populated (you can change though); leave them to as is.

  4. To test the EFS created, you can create two instances of EC2, each in two different AZs. These instances needs to be in the same security group as the EFS mount point we created. You can change security groups by selecting the instance and going to Actions > Networking > Change Security groups (you can select the default one also if EFS is using it).

  5. Next you can launch all instances.

  6. Provision a load balancer similar to older labs.

  7. Connect to both EC2 instances through ssh and elevate permissions to root. Install apache, and start the apache service.

  8. If you go to your EFS, you can get mount instructions. Most of the initial steps would be already done if you are using Amazon Linux AMI. All you need to do is to copy and use the sudo mount commands, but instead of mounting to a folder efs, replace it with /var/www/html (do for both instances). Now go inside /var/www/html (in one instance) and create index.html file. In  the second instance also, you should see this file now (go to the folder and do an ls).

  9. You can now go to your ELB and should see that the health check is passing.

  10. You can also run the dns name for the load balancer.    

Note: Do proper cleanup before you leave the lab.

Recipe Tags: 

Learn Serverless from Serverless Programming Cookbook

Contact

Please first use the contact form or facebook page messaging to connect.

Offline Contact
We currently connect locally for discussions and sessions at Bangalore, India. Please follow us on our facebook page for details.
WhatsApp (Primary): (+91) 7411174113
Phone (Escalations): (+91) 7411174114

Business newsletter

Complete the form below, and we'll send you an e-mail every now and again with all the latest news.

About

CloudMaterials is my blog to share notes and learning materials on Cloud and Data Analytics. My current focus is on Microsoft Azure and Amazon Web Services (AWS).

I like to write and I try to document what I learn to share with others. I believe that knowledge is useless unless you share it; the more you share, the more you learn.

Recent comments

Photo Stream