@@ -33,13 +33,16 @@ 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 }
3639 EcrImageTag : { Type: AWS::SSM::Parameter::Value<String> }
3740 AlbListenerRulePriorityPrefix : { Type: String }
38- Aarch64AsgCapacityProviderName : { Type: String }
3941 MysqlHostname : { Type: String }
4042 ValkeyHostname : { Type: String }
4143 ValkeyPort : { Type: String }
4244 AlbAccessToken : { Type: AWS::SSM::Parameter::Value<String> }
45+ SharedEcsAsgInstanceSecurityGroupId : { Type: AWS::EC2::SecurityGroup::Id }
4346
4447Conditions :
4548 IsProduction : !Equals [!Ref EnvironmentType, Production]
@@ -183,6 +186,7 @@ Resources:
183186 TargetGroupAttributes :
184187 - Key : deregistration_delay.timeout_seconds
185188 Value : " 30"
189+ TargetType : ip
186190 Tags :
187191 - { Key: Name, Value: !Sub "${RootStackName}_wordpress" }
188192 - { Key: prx:meta:tagging-version, Value: "2021-04-07" }
@@ -261,24 +265,27 @@ Resources:
261265 WebEcsService :
262266 Type : AWS::ECS::Service
263267 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
275276 LoadBalancers :
276277 - ContainerName : !Ref kWebContainerName
277278 ContainerPort : !Ref kWebApplicationPort
278279 TargetGroupArn : !Ref WebTargetGroup
279- PlacementConstraints :
280- - Type : memberOf
281- Expression : attribute:ecs.cpu-architecture == arm64
280+ NetworkConfiguration :
281+ AwsvpcConfiguration :
282+ AssignPublicIp : ENABLED
283+ SecurityGroups :
284+ - !Ref SharedEcsAsgInstanceSecurityGroupId
285+ Subnets :
286+ - !Ref VpcPublicSubnet1Id
287+ - !Ref VpcPublicSubnet2Id
288+ - !Ref VpcPublicSubnet3Id
282289 PropagateTags : TASK_DEFINITION
283290 Tags :
284291 - { Key: prx:meta:tagging-version, Value: "2021-04-07" }
@@ -308,9 +315,10 @@ Resources:
308315 WebTaskDefinition :
309316 Type : AWS::ECS::TaskDefinition
310317 Properties :
318+ Cpu : !If [IsProduction, 2048, 512] # 512 = 0.5 vCPU, 2048 = 2 vCPU, etc
319+ Memory : !If [IsProduction, 8192, 2048]
311320 ContainerDefinitions :
312- - Cpu : 100 # Currently we don't use CPU reservations for anything meaningful
313- Environment :
321+ - Environment :
314322 - Name : PRX_ENVIRONMENT
315323 Value : !Ref EnvironmentTypeLowercase
316324 - Name : DB_HOST
@@ -373,17 +381,10 @@ Resources:
373381 awslogs-group : !Ref WebTaskLogGroup
374382 awslogs-region : !Ref AWS::Region
375383 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]
383384 Name : !Ref kWebContainerName
384385 PortMappings :
385386 - ContainerPort : !Ref kWebApplicationPort
386- HostPort : 0
387+ Protocol : tcp
387388 Secrets :
388389 - Name : AUTH_KEY
389390 ValueFrom : !Sub /prx/${EnvironmentTypeAbbreviation}/Terra/The_World-WordPress/auth-key
@@ -416,7 +417,9 @@ Resources:
416417 - Name : DB_PASSWORD
417418 ValueFrom : !Sub /prx/${EnvironmentTypeAbbreviation}/Terra/The_World-WordPress/mysql/password
418419 ExecutionRoleArn : !GetAtt ExecutionRole.Arn
419- NetworkMode : bridge
420+ NetworkMode : awsvpc
421+ RequiresCompatibilities :
422+ - FARGATE
420423 Tags :
421424 - { Key: prx:meta:tagging-version, Value: "2021-04-07" }
422425 - { Key: prx:cloudformation:stack-name, Value: !Ref AWS::StackName }
0 commit comments