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:
-
Go to AWS console and go to EFS.
-
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.
-
Subnets for each AZ and security groups for the selected VPC will be automatically populated (you can change though); leave them to as is.
-
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).
-
Next you can launch all instances.
-
Provision a load balancer similar to older labs.
-
Connect to both EC2 instances through ssh and elevate permissions to root. Install apache, and start the apache service.
-
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).
-
You can now go to your ELB and should see that the health check is passing.
-
You can also run the dns name for the load balancer.
Note: Do proper cleanup before you leave the lab.
Recent comments