输出云形成列表

时间:2017-11-30 16:31:12

标签: amazon-cloudformation

我有一个参数:

  ClusterSubnets:
    Description: Subnets where cluster will reside.
                Typically private.  Use mutiples, each in a different AZ for HA.
    ConstraintDescription: comma separated list of valid Subnet IDs
    Type: List<AWS::EC2::Subnet::Id>

我正在尝试输出:

  ClusterSubnets:
    Description: Subnets used by cluster
    Value: !Ref ClusterSubnets
    Export:
      Name: !Sub "${AWS::StackName}-ClusterSubnets"

但我收到此错误:模板格式错误:每个Outputs成员的Value字段必须求值为String。

如何导出列表?

1 个答案:

答案 0 :(得分:5)

您需要将列表的元素连接成一个字符串。尝试这样的事情:

ClusterSubnets:
    Description: Subnets used by cluster
    Value: !Join
        - ','
        - !Ref ClusterSubnets
    Export:
        Name: !Sub "${AWS::StackName}-ClusterSubnets"

以下是相关的AWS documentation