我已经在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
。为什么条件语句解析为“否”而不是"is"?在条件中使用SSM参数存储值的正确方法是什么?
参数商店截图:
环境变量屏幕截图:
最佳答案
我可以使用以下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
关于amazon-web-services - 如何在Cloudformation模板条件中使用AWS SSM参数存储值?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59735832/