CloudFormation - 动态生成描述
CloudFormation - Dynamically Generate Description
我有一个 CloudFormationScript,其定义如下:
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "My Cluster-GREEN",
...
我想通过我通过参数 (BLUE/GREEN) 传递给 CFT 的参数动态生成上面的 -GREEN。我该怎么做?
根据官方文档here,
The value for the description declaration must be a literal string that is between 0 and 1024 bytes in length. You cannot use a parameter or function to specify the description.
因此,您不能使用参数动态传递描述。
如果您使用的是 SDK,则有一个解决方法。由于 CFn 模板是 JSON,您可以在调用 createStack 方法之前使用您想要的任何值设置描述。
伪代码:
Map<String, Object> template = readTemplateFromResources();
template["description"] = "My Cluster-GREEN";
createStackRequest.setTemplateBody(template.toString());
希望对您有所帮助。
我有一个 CloudFormationScript,其定义如下:
{ "AWSTemplateFormatVersion": "2010-09-09", "Description": "My Cluster-GREEN", ...
我想通过我通过参数 (BLUE/GREEN) 传递给 CFT 的参数动态生成上面的 -GREEN。我该怎么做?
根据官方文档here,
The value for the description declaration must be a literal string that is between 0 and 1024 bytes in length. You cannot use a parameter or function to specify the description.
因此,您不能使用参数动态传递描述。
如果您使用的是 SDK,则有一个解决方法。由于 CFn 模板是 JSON,您可以在调用 createStack 方法之前使用您想要的任何值设置描述。
伪代码:
Map<String, Object> template = readTemplateFromResources();
template["description"] = "My Cluster-GREEN";
createStackRequest.setTemplateBody(template.toString());
希望对您有所帮助。