sparse-intern-71089
04/03/2021, 8:44 PMagreeable-ram-97887
04/03/2021, 8:45 PM# Create an EFS File System
shared_file_system = aws.efs.FileSystem(
"shared_file_system",
lifecycle_policy=aws.efs.FileSystemLifecyclePolicyArgs(
transition_to_ia="AFTER_7_DAYS",
),
encrypted=False, # TODO: Add encryption
performance_mode="generalPurpose", # could also be: "maxIO"
tags={
"Environment": ENV,
"Scope": PROJECT_SCOPE,
"Name": f"{PROJECT_SCOPE}-shared-file-system-{ENV}",
},
)
nfs_security_group = aws.ec2.SecurityGroup(
"shared-file-system-security-group",
vpc_id=vpc.id,
description="Allow all NFS traffic",
tags={
"Name": f"{PROJECT_SCOPE}-nfs-sg-{ENV}",
"Scope": PROJECT_SCOPE,
},
ingress=[
aws.ec2.SecurityGroupIngressArgs(
cidr_blocks=["0.0.0.0/0"],
from_port=2049,
to_port=2049,
protocol="tcp",
description="Allow NFS traffic",
),
],
)
shared_file_system_mount_targets = []
for subnet in subnets:
mount_target = aws.efs.MountTarget(
f"efs-mount-target-{subnet.id}",
file_system_id=shared_file_system.id,
subnet_id=subnet.id,
security_groups=[nfs_security_group.id],
# ip_address=ip,
opts=pulumi.ResourceOptions(delete_before_replace=True),
)
shared_file_system_mount_targets.append(mount_target)