Created
April 22, 2022 08:04
-
-
Save wcheek/59064888c3552cf822c05cb5dd941e27 to your computer and use it in GitHub Desktop.
AWS CDK EC2 instance with EFS attached
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.file_system.connections.allow_default_port_from(self.ec2_instance) | |
self.ec2_instance.user_data.add_commands( | |
"yum check-update -y", | |
"yum upgrade -y", | |
"yum install -y amazon-efs-utils", | |
"yum install -y nfs-utils", | |
"file_system_id_1=" + self.file_system.file_system_id, | |
"efs_mount_point_1=/mnt/efs/fs1", | |
'mkdir -p "${efs_mount_point_1}"', | |
'test -f "/sbin/mount.efs" && echo "${file_system_id_1}:/ ${efs_mount_point_1} efs defaults,_netdev" >> /etc/fstab || " + "echo "${file_system_id_1}.efs." + Stack.of(self).region + ".amazonaws.com:/ ${efs_mount_point_1} nfs4 nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport,_netdev 0 0" >> /etc/fstab', | |
"mount -a -t efs,nfs4 defaults", | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actually this one is probably better: