【发布时间】:2021-07-10 19:29:34
【问题描述】:
这是我的(缩短的)template.yml 文件:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: CF template for foobar
Parameters:
EnvType:
Type: String
Description: The environment to deploy to.
AllowedValues:
- dev1
- qc1
- uat1
Default: dev1
VeryImportantFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/very_important/
Handler: app.very_important
Runtime: python3.8
{unrelated policies and environment variables}
Events:
VeryImportantSchedule:
Type: Schedule
Properties:
Schedule: 'rate(2 hours)'
Enabled: True
我要做的只是在 EnvType 参数设置为 qc1 时启用该计划。问题是,我无法让Equals condition 或If condition 工作。我已经尝试了以下所有方法:
Enabled: !Equals [!Ref EnvType, qc1]
Enabled: !Equals [!Ref EnvType, "qc1"]
和
Conditions:
IsQcEnv: !Equals [!Ref EnvType, qc1]
{and}
IsQcEnv: !Equals [!Ref EnvType, "qc1"]
....
....
....
Events:
VeryImportantSchedule:
Type: Schedule
Properties:
Schedule: 'rate(2 hours)'
Enabled: !If [IsQcEnv, True, False]
在测试所有这四种情况之间,我删除了我的整个堆栈,而不是尝试更新它们,作为this post suggested. 中的评论,我还三次检查传入的参数不是 qc1,并且还设置了启用标志为 False 以确保它实际上会禁用计划,它确实这样做了。在这一点上我很困惑,有没有人知道我做错了什么或者我可以尝试什么?
【问题讨论】:
-
为什么它不起作用?有任何错误信息吗? Parring 错误?语法错误?堆栈回滚?
-
@Marcin:我遇到了同样的问题。 AWS 没有抱怨,但计划始终处于启用状态。
标签: amazon-web-services amazon-cloudformation aws-event-bridge