【发布时间】:2019-02-12 04:18:43
【问题描述】:
我有以下 cloudformation 模板。目标是仅在用户需要时创建参数组,然后使用 cloudformation 模板参数的内容填充参数组中的 RDS 参数。
Parameters:
UseCustomParameterGroup:
Description: Toggle to 'Yes' to create a new parameter group.
Type: String
AllowedValues: ['Yes', 'No']
Default: 'No'
CustomParameters:
Description: Add custom parameters to your custom parameter group. Creating a custom parameter group without parameters creates a mirror of the default group.
Type: String
Conditions:
UseCustomParameterGroup: !Equals [!Ref 'UseCustomParameterGroup', 'Yes']
Resources:
CustomParameterGroup:
Type: AWS::RDS::DBParameterGroup
Condition: 'UseCustomParameterGroup'
Properties:
Family: "postgres10"
Parameters: !Ref "CustomParameters"
如果我这样从另一个模板调用此模板,它将失败并出现错误Value of property Parameters must be an object
Parameters:
USECUSTOMPARAMETERGROUP: 'Yes'
CUSTOMPARAMETERS: '{
"shared_preload_libraries": "pg_stat_statements",
"pg_stat_statements.track": "all"
}'
Resources:
Postgres:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: https://..../rds-postgres-instance.yaml
TimeoutInMinutes: '60'
Parameters:
UseCustomParameterGroup: !Ref USECUSTOMPARAMETERGROUP
CustomParameters: !Ref CUSTOMPARAMETERS
AWS::RDS::DBParameterGroup 的文档说明了 Parameters 参数的以下内容:
类型:由字符串键值对组成的 JSON 对象,如下例所示
“参数”:{“Key1”:“Value1”,“Key2”:“Value2”,“Key3”:“Value3”}
我认为这对于 Cloudformation 的 YAML 版本可能已经过时,但没有关于如何将此值传递给多个参数的文档。
我希望用户能够定义任意数量的 RDS 参数,而不必考虑 RDS 可用的数千个可能参数中的任何一个。
【问题讨论】:
标签: yaml amazon-cloudformation