There's more...

To confirm that your EFS filesystem, mount targets, and security groups are working, you can also provision 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. Still in the Resources section, add a launch configuration:
      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\nchown ec2-user: ${MountPoint}\n"
  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-working-with-network-storage.yaml \
--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 SSH to your instances and verify  
             that they have mounted the EFS filesystem.