There's moreā€¦

To confirm that your EFS filesystem, mount targets, and security groups are working, you can also provide some client instances to connect to them. Add the following resources and parameters to the template you have already created:

  1. Add the following parameters to your top-level Parameters section to configure your instances:
      MountPoint: 
Description: The path on disk to mount the EFS file system
Type: String
Default: /mnt/efs
KeyName:
Description: The SSH key pair allowed to connect to the client
instance
Type: AWS::EC2::KeyPair::KeyName
  1. Add an AutoScalingGroup under the Resources section. Regardless of which AZ your servers are provisioned to, they will have access to the EFS filesystem via the local mount point:
      AutoScalingGroup: 
Type: AWS::AutoScaling::AutoScalingGroup
DependsOn: MountTargetA
Properties:
MinSize: 2
MaxSize: 2
LaunchConfigurationName:
Ref: LaunchConfiguration
Tags:
- Key: Name
Value:
Fn::Sub: "${AWS::StackName} EFS Client"
PropagateAtLaunch: true
VPCZoneIdentifier:
Ref: SubnetIds
  1. While still in the Resources section, add a LaunchConfiguration:
      LaunchConfiguration: 
Type: AWS::AutoScaling::LaunchConfiguration
DependsOn: FileSystem
Properties:
ImageId: ami-1e299d7e
SecurityGroups:
- Ref: MountTargetAccessSecurityGroup
InstanceType: t2.micro
KeyName:
Ref: KeyName
UserData:
Fn::Base64:
Fn::Sub: |
#!/bin/bash -xe
mkdir -p ${MountPoint}
echo 'Waiting for mount target DNS to propagate'
sleep 90
echo '${FileSystem}.efs.${AWS::Region}.amazonaws.com:/
${MountPoint} nfs4
nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,
retrans=2 0 0' >>
/etc/fstab
mount -a chown ec2-user: ${MountPoint} "
  1. Launch the cloudformation stack with the following AWS CLI command, substituting your own parameter values:
      aws cloudformation create-stack  
--stack-name wwns1
--template-body file://03-03-NetworkStorage.yml
--parameters
ParameterKey=VpcId,ParameterValue=<vpc-id>
ParameterKey=SubnetIds,ParameterValue='<subnet-id-1>,
<subnet-id-1>'

ParameterKey=MountPoint,ParameterValue=<local-path-to-mount-efs>
ParameterKey=KeyName,ParameterValue=<existing-key-pair-name>

Once the new stack is ready, you will be able to Secure Shell (SSH) to your instances and verify that they have mounted the EFS filesystem.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset