From 7290615791393f15f636eb616e76ae7e7d2384c5 Mon Sep 17 00:00:00 2001 From: Andrew Peabody Date: Sun, 16 Jan 2022 13:56:38 -0700 Subject: ADD: EFS Improvements -EFS retained upon stack deletion to preserve saves. -EFS lifecycle management enabled to lower cost when not actively utilized. -Migrate to CloudFormation's native EFS handler for ECS tasks. Removes the ASG dependency on the EFS mount points for increased parallelization during build-out. However, migrating save files is slightly complicated. --- cf.yml | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'cf.yml') diff --git a/cf.yml b/cf.yml index 5517bb9..7b2bd32 100644 --- a/cf.yml +++ b/cf.yml @@ -196,7 +196,11 @@ Resources: Efs: Type: AWS::EFS::FileSystem - Properties: {} + DeletionPolicy: Retain + Properties: + LifecyclePolicies: + - TransitionToIA: AFTER_7_DAYS + - TransitionToPrimaryStorageClass: AFTER_1_ACCESS MountA: Type: AWS::EFS::MountTarget @@ -271,17 +275,10 @@ Resources: UserData: Fn::Base64: !Sub | #!/bin/bash -xe - yum install -y amazon-efs-utils - mkdir /opt/factorio - mount -t efs ${Efs}:/ /opt/factorio - chown 845:845 /opt/factorio echo ECS_CLUSTER=${EcsCluster} >> /etc/ecs/ecs.config AutoScalingGroup: Type: AWS::AutoScaling::AutoScalingGroup - DependsOn: - - MountA - - MountB Properties: AutoScalingGroupName: !Sub "${AWS::StackName}-asg" DesiredCapacity: !FindInMap [ ServerState, !Ref ServerState, DesiredCapacity ] @@ -339,11 +336,15 @@ Resources: EcsTask: Type: AWS::ECS::TaskDefinition + DependsOn: + - MountA + - MountB Properties: Volumes: - - Host: - SourcePath: /opt/factorio - Name: factorio + - Name: factorio + EFSVolumeConfiguration: + FilesystemId: !Ref Efs + TransitEncryption: ENABLED ContainerDefinitions: - Name: factorio MemoryReservation: 1024 -- cgit v1.2.3