创建firehose云信息模板时出错

时间:2017-10-24 23:20:13

标签: amazon-web-services amazon-cloudformation

我正在创建一个“firehose”cloudformation模板,最终将数据推送到redshift

它看起来像这样:

{
  "Resources": {
     "Role1" : {},// this role permits access to S3 and Redshift

     "S3Bucket" : {} // configuration for S3 bucket where firehose places data before pushing it to redshift

     "RedshiftCluster": {} // configuration for redshift cluster

     "FirehoseStream": {
        ... some properties here
       "RedshiftDestinationConfiguration" : {
           "ClusterJDBCURL": {
            "Fn::GetAtt": [
              "RedshiftCluster",
              "ClusterJDBCURL"
            ]
         }

        },

     }
  }


}

我收到的错误是:

Template validation error: Template error: resource RedshiftCluster does not support attribute type ClusterJDBCURL in Fn::GetAtt

根据文档,ClusterJDBCURL的值必须是“String”。但是,在设置redshift集群之前,我不会知道此字符串的值。

我想如何提供这个值呢?

2 个答案:

答案 0 :(得分:1)

AWS::Redshift::Cluster类型没有ClusterJDBCURL属性。 但是,我们可以使用Fn::Sub构建一个。

根据Obtain the JDBC Url文档, JDBC Url 的格式为jdbc:redshift://<endpoint>:<port>/<database>

因此,如果您将以下示例中的<database>替换为数据库名称,则应该获得您正在寻找的内容。

{
  "Resources": {
    "Role1" : {},// this role permits access to S3 and Redshift
    "S3Bucket" : {} // configuration for S3 bucket where firehose places data before pushing it to redshift

    "RedshiftCluster": {} // configuration for redshift cluster

    "FirehoseStream": {
        ... some properties here
      "RedshiftDestinationConfiguration" : {
        "ClusterJDBCURL": {
          "Fn::Sub": "jdbc:redshift://${RedshiftCluster.Endpoint.Address}:${RedshiftCluster.Endpoint.Port}/<database>"
        }
      },
    }
  }
}

答案 1 :(得分:0)

另一种语法,在serverless.yml内部很有用

          ClusterJDBCURL:
            Fn::Join:
              - ""
              - - "jdbc:redshift://"
                - Fn::GetAtt: [RedShiftCluster, Endpoint.Address]
                - ":"
                - Fn::GetAtt: [RedShiftCluster, Endpoint.Port]
                - "/<database>"