@@ -33,16 +33,13 @@ Parameters:
3333 RootStackName : { Type: String }
3434 RootStackId : { Type: String }
3535 VpcId : { Type: AWS::EC2::VPC::Id }
36- VpcPublicSubnet1Id : { Type: AWS::EC2::Subnet::Id }
37- VpcPublicSubnet2Id : { Type: AWS::EC2::Subnet::Id }
38- VpcPublicSubnet3Id : { Type: AWS::EC2::Subnet::Id }
3936 EcrImageTag : { Type: AWS::SSM::Parameter::Value<String> }
4037 AlbListenerRulePriorityPrefix : { Type: String }
38+ Aarch64AsgCapacityProviderName : { Type: String }
4139 MysqlHostname : { Type: String }
4240 ValkeyHostname : { Type: String }
4341 ValkeyPort : { Type: String }
4442 AlbAccessToken : { Type: AWS::SSM::Parameter::Value<String> }
45- SharedEcsAsgInstanceSecurityGroupId : { Type: AWS::EC2::SecurityGroup::Id }
4643
4744Conditions :
4845 IsProduction : !Equals [!Ref EnvironmentType, Production]
@@ -186,7 +183,6 @@ Resources:
186183 TargetGroupAttributes :
187184 - Key : deregistration_delay.timeout_seconds
188185 Value : " 30"
189- TargetType : ip
190186 Tags :
191187 - { Key: Name, Value: !Sub "${RootStackName}_wordpress" }
192188 - { Key: prx:meta:tagging-version, Value: "2021-04-07" }
@@ -265,27 +261,24 @@ Resources:
265261 WebEcsService :
266262 Type : AWS::ECS::Service
267263 Properties :
264+ CapacityProviderStrategy :
265+ - Base : 0
266+ CapacityProvider : !Ref Aarch64AsgCapacityProviderName
267+ Weight : 1
268268 Cluster : !Ref EcsClusterArn
269269 DeploymentConfiguration :
270270 MaximumPercent : 200
271271 MinimumHealthyPercent : 50
272272 DesiredCount : !If [IsProduction, 5, 1]
273273 EnableECSManagedTags : true
274274 EnableExecuteCommand : true
275- LaunchType : FARGATE
276275 LoadBalancers :
277276 - ContainerName : !Ref kWebContainerName
278277 ContainerPort : !Ref kWebApplicationPort
279278 TargetGroupArn : !Ref WebTargetGroup
280- NetworkConfiguration :
281- AwsvpcConfiguration :
282- AssignPublicIp : ENABLED
283- SecurityGroups :
284- - !Ref SharedEcsAsgInstanceSecurityGroupId
285- Subnets :
286- - !Ref VpcPublicSubnet1Id
287- - !Ref VpcPublicSubnet2Id
288- - !Ref VpcPublicSubnet3Id
279+ PlacementConstraints :
280+ - Type : memberOf
281+ Expression : attribute:ecs.cpu-architecture == arm64
289282 PropagateTags : TASK_DEFINITION
290283 Tags :
291284 - { Key: prx:meta:tagging-version, Value: "2021-04-07" }
@@ -315,10 +308,9 @@ Resources:
315308 WebTaskDefinition :
316309 Type : AWS::ECS::TaskDefinition
317310 Properties :
318- Cpu : !If [IsProduction, 2048, 512] # 512 = 0.5 vCPU, 2048 = 2 vCPU, etc
319- Memory : !If [IsProduction, 8192, 2048]
320311 ContainerDefinitions :
321- - Environment :
312+ - Cpu : 100 # Currently we don't use CPU reservations for anything meaningful
313+ Environment :
322314 - Name : PRX_ENVIRONMENT
323315 Value : !Ref EnvironmentTypeLowercase
324316 - Name : DB_HOST
@@ -381,10 +373,17 @@ Resources:
381373 awslogs-group : !Ref WebTaskLogGroup
382374 awslogs-region : !Ref AWS::Region
383375 awslogs-stream-prefix : ecs
376+ # Memory and MemoryReservation values are based on current instances
377+ # sizes, ensuring that only 1 WordPress task is running on any
378+ # instance
379+ # Prod: c8g.xlarge => 8 GiB
380+ # Stag: t4g.small => 2 GiB
381+ Memory : !If [IsProduction, 7650, 1800]
382+ MemoryReservation : !If [IsProduction, 4111, 1111]
384383 Name : !Ref kWebContainerName
385384 PortMappings :
386385 - ContainerPort : !Ref kWebApplicationPort
387- Protocol : tcp
386+ HostPort : 0
388387 Secrets :
389388 - Name : AUTH_KEY
390389 ValueFrom : !Sub /prx/${EnvironmentTypeAbbreviation}/Terra/The_World-WordPress/auth-key
@@ -417,9 +416,7 @@ Resources:
417416 - Name : DB_PASSWORD
418417 ValueFrom : !Sub /prx/${EnvironmentTypeAbbreviation}/Terra/The_World-WordPress/mysql/password
419418 ExecutionRoleArn : !GetAtt ExecutionRole.Arn
420- NetworkMode : awsvpc
421- RequiresCompatibilities :
422- - FARGATE
419+ NetworkMode : bridge
423420 Tags :
424421 - { Key: prx:meta:tagging-version, Value: "2021-04-07" }
425422 - { Key: prx:cloudformation:stack-name, Value: !Ref AWS::StackName }
0 commit comments