类型为 StringList 的 cloudformation SSM 动态引用能否解析为列表?

ekc*_*isp 5 aws-cloudformation amazon-systems-manager

在 cloudformation 模板中支持对 SSM 参数的动态引用

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html

该文档指出,您可以 Use the ssm dynamic reference to include values stored in the Systems Manager Parameter Store of type String or StringList in your templates.

我们尝试使用语法在模板中引用类型为 StringList 的参数,{{resolve:ssm:parameter-name:version}}并将其解析为模板中的字符串列表(更具体地说,是 EC2 实例的 SecurityGroupId 列表)。这不起作用,并且文档没有指定如何执行此操作或是否受支持。我们已经尝试使用,Fn::Split但是它似乎在动态值得到解决之前被调用。我们无法在模板的参数部分中使用 SSM 值,该部分已记录在案。有谁知道是否有可能需要{{resolve ...一个字符串列表?

wjo*_*dan 6

在等待 AWS 实现{{resolve: ...动态引用的待处理功能请求以解析为“字符串列表”类型时,您可以使用当前的SSM 参数类型以及AWS::SSM::Parameter::Value<List<String>>与您要引用的 SSM 参数相对应的默认值来解决此问题:

Parameters:
  SecurityGroups:
    Type: AWS::SSM::Parameter::Value<List<String>>
    Default: security-groups
Resources:
  Type: AWS::EC2::Instance
  Properties:
    SecurityGroupIds: !Ref SecurityGroups
Run Code Online (Sandbox Code Playgroud)


ekc*_*isp 5

AWS Support 已回复我关于此问题的请求,并解释说我的问题的答案是否定的,目前不支持。他们的回复全文如下。

目前,CFN 可以采用 StringList 类型,但这种 StringList 正在作为逗号分隔的字符串值返回,从而产生一个长字符串。因此,如果我们需要将它变成多个值,如数组或字符串列表,例如 EC2 实例的 SecurityGroup Id 列表,目前不支持。

话虽如此,我进一步挖掘并发现我们在内部将此作为现有功能请求,我已将您的声音添加到其中以帮助获得此功能的更多吸引力。我没有 ETA 可以分享,因为服务团队对他们的时间表/工作日志持谨慎态度。但是,如果/当该功能可用时,应在以下地点公示:

  • AWS 最新消息:https : //aws.amazon.com/new/
  • CloudFormation 发布历史:https ://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/ReleaseHistory.html