[英]How to use AWS SSM parameter store values in Cloudformation template conditionals?
I have configured a key value pair in the AWS SSM parameter store UI as my-ssm-key
= ssm-value
.我已在 AWS SSM 参数存储 UI 中将键值对配置为
my-ssm-key
= ssm-value
。
I have the following YAML template for CF built on 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'
On deploying the stack, environment variables are being set to ssm_value
= ssm-value
and ssm_value_is_correct
= no
.在部署堆栈时,环境变量被设置为
ssm_value
= ssm-value
和ssm_value_is_correct
= no
。
Why is the conditional statement resolving to "no" instead of "yes"?为什么条件语句解析为“否”而不是“是”? What is the correct way to use SSM parameter store values in conditionals?
在条件中使用 SSM 参数存储值的正确方法是什么?
Param store screenshot:参数存储截图:
Env variables screenshot:
环境变量截图:
I was able to resolve the issue by using this CF template:我能够通过使用这个 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.