Amazon web services 如何在CloudFormation中使用ECS placementConstraints
我试图在使用CloudFormation的服务定义中使用Amazon web services 如何在CloudFormation中使用ECS placementConstraints,amazon-web-services,amazon-cloudformation,amazon-ecs,Amazon Web Services,Amazon Cloudformation,Amazon Ecs,我试图在使用CloudFormation的服务定义中使用placementConstraints,但它在AWS::ECS::service资源中不作为属性存在。有解决办法吗 ECS服务: CloudFormation ECS服务资源:PlacementConstraint在撰写本文时作为AWS::ECS::Service的属性存在。引用AWS文件: PlacementConstraint是AWS::ECS::Service资源的属性 为服务中的任务指定放置约束的 与Amazon EC2容器服务(
placementConstraints
,但它在AWS::ECS::service
资源中不作为属性存在。有解决办法吗
ECS服务:
CloudFormation ECS服务资源:
PlacementConstraint
在撰写本文时作为AWS::ECS::Service
的属性存在。引用AWS文件:
PlacementConstraint是AWS::ECS::Service资源的属性
为服务中的任务指定放置约束的
与Amazon EC2容器服务(Amazon ECS)关联
服务
Ref:
[1]
[2]这对我来说很有用!如果使用yaml,错误的缩进可能会导致此错误
ApplicationService:
Type: AWS::ECS::Service
DependsOn:
- ALBListener
- ApplicationTaskDefinition
- ALBTargetGroup
Properties:
Cluster:
'Fn::ImportValue': !Sub ecs-${EnvironmentName}-clustername
DesiredCount: 15
LoadBalancers:
- ContainerName: !Sub ${AWS::StackName}-app
ContainerPort: 8080
TargetGroupArn: !Ref ALBTargetGroup
Role:
'Fn::ImportValue': !Sub ecs-${EnvironmentName}-servicerole-arn
TaskDefinition: !Ref ApplicationTaskDefinition
PlacementConstraints:
- Expression: attribute:ecs.instance-type == t2.medium
Type: memberOf
PlacementStrategies:
- Type: spread
Field: attribute:ecs.availability-zone
如果这对你不起作用,请在这里发布你的cfn文件
PlacementConstraints
现在也存在于AWS::ECS::TaskDefinition
: