gpt4 book ai didi

amazon-web-services - Cloudformation 条件语句

转载 作者:行者123 更新时间:2023-12-03 07:41:06 26 4
gpt4 key购买 nike

我正在尝试使用用于登录 ECS TaskDefination 的条件语句为 ECS 服务创建堆栈。我正在尝试根据环境将日志发送到不同的源,但在堆栈更新期间失败,如下所示。

错误资源处理程序返回消息:“模型验证失败(#/ContainerDefinitions/0/Memory:预期类型:Number,找到:String #/ContainerDefinitions/0/Cpu:预期类型:Number,找到:String #/ContainerDefinitions/0/LogConfiguration:预期类型:JSONObject,找到:JSONArray #/ContainerDefinitions/0/PortMappings/0/ContainerPort:预期类型:Number,找到:String)"

Conditions:
HasDefaultLog:
!Or [ !Equals [ !Ref EnvType, 'Prod' ], !Equals [ !Ref EnvType, 'Dev' ], !Equals [ !Ref EnvType, 'Sit' ] ]

ContainerDefinitions:
- Name: !Ref 'ServiceName'
Cpu: !Ref 'ContainerCpu'
Memory: !Ref 'ContainerMemory'
Image: !Ref 'ImageUrl'
PortMappings:
- ContainerPort: !Ref 'ContainerPort'
LogConfiguration:
-
Fn::If:
- HasDefaultLog
-
LogDriver: !Ref LogDriver
Options:
syslog-address: !Ref LogDestination
tag: !Ref ServiceName
-
LogDriver: awsfirelens
Options:
Name: newlogdriver

下面的操作相同,并且能够在目标中查看日志

LogConfiguration:
LogDriver: !Ref LogDriver
Options:
syslog-address: !Ref LogDestination
tag: !Ref ServiceName

最佳答案

LogConfiguration 是对象,而不是对象列表。 Sp 你不需要在开头 - :

          LogConfiguration:
Fn::If:
- HasDefaultLog
-
LogDriver: !Ref LogDriver
Options:
syslog-address: !Ref LogDestination
tag: !Ref ServiceName
-
LogDriver: awsfirelens
Options:
Name: newlogdriver

关于amazon-web-services - Cloudformation 条件语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68138552/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com