创建 firehose cloudformation 模板时出错

Error in creating firehose cloudformation template

我正在创建一个 "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 集群之前,我不会知道这个字符串的值。

那我应该如何提供这个值?

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>"
        }
      },
    }
  }
}

另一种语法,里面有用serverless.yml

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