我在AWS SSM参数存储UI中配置了一个键值对my-ssm-key = ssm-value。
我有以下基于Serverless构建的CF的YAML模板:
service: redirect-test
provider:
name: aws
runtime: python3.8
environment:
ssm_value: '{{resolve:ssm:my-ssm-key:1}}'
ssm_value_is_correct: !If [SSM_KEY_IS_CORRECT, yes, no]
functions:
hello:
handler: handler.hello
resources:
Conditions:
SSM_KEY_IS_CORRECT:
!Equals
- '{{resolve:ssm:my-ssm-key:1}}'
- 'ssm-value'在部署堆栈时,环境变量被设置为ssm_value = ssm-value和ssm_value_is_correct = no。
为什么条件语句解析为"no“而不是"yes"?在条件句中使用SSM参数存储值的正确方式是什么?
Param store截图:

环境变量屏幕截图:

发布于 2020-01-18 00:17:14
我能够通过使用这个CF模板解决这个问题:
service: redirect-test
provider:
name: aws
runtime: python3.8
environment:
ssm_value: !Ref MySSMValue
ssm_value_is_correct: !If [SSM_KEY_IS_CORRECT, yes, no]
functions:
hello:
handler: handler.hello
resources:
Conditions:
SSM_KEY_IS_CORRECT:
!Equals
- !Ref MySSMValue
- ssm-value
Parameters:
MySSMValue:
Description: My SSM Value
Type: AWS::SSM::Parameter::Value<String>
Default: my-ssm-key

https://stackoverflow.com/questions/59735832
复制相似问题