【问题标题】:Receiving Error Property validation failure: [Value of property {/TableInput/ViewOriginalText} does not match type {String}] AWS cloudformation接收错误属性验证失败:[属性值 {/TableInput/ViewOriginalText} 与类型 {String} 不匹配] AWS cloudformation
【发布时间】:2020-09-06 01:34:54
【问题描述】:

我正在尝试使用表中的数据创建外部视图,但收到错误属性验证失败:[属性值 {/TableInput/ViewOriginalText} 与类型 {String} 不匹配],同时使用云形成在 AWS 胶水中创建视图.

任何关于分辨率的想法都将不胜感激。下面是我正在使用的yaml文件代码sn-p。

提前致谢

---
AWSTemplateFormatVersion: 2010-09-09
Description: "Glue Athena database and table configuration"
Parameters:

  MarketingAndSalesDatabaseName:
    Type: String
    MinLength: "4"
    Default: "marketingandsales_qs"
    Description: "Name of the AWS Glue database to contain this CloudFormation template's tables."

  SalesPipelineTableName:
    Type: String
    MinLength: "4"
    Default: "salespipeline_qs"
    Description: "Name of the Sales Pipeline data table in AWS Glue."

Resources:

  ### AWS GLUE RESOURCES ###

  MarketingAndSalesDatabase:
    Type: "AWS::Glue::Database"
    Properties:
      DatabaseInput:
        Description: "Marketing and Sales database (Amazon QuickSight Samples)."
        Name: !Ref MarketingAndSalesDatabaseName
      CatalogId: !Ref AWS::AccountId

  SalesPipelineTable:
    Type: "AWS::Glue::Table"
    DependsOn: MarketingAndSalesDatabase
    Properties:
      TableInput:
        Description: "Sales Pipeline table (Amazon QuickSight Sample)."
        TableType: "VIRTUAL_VIEW"
        Parameters: {
                "CrawlerSchemaDeserializerVersion": "1.0",
                "compressionType": "none",
                "classification": "csv",
                "recordCount": "16831",
                "typeOfData": "file",
                "CrawlerSchemaSerializerVersion": "1.0",
                "columnsOrdered": "true",
                "objectCount": "1",
                "delimiter": ",",
                "skip.header.line.count": "1",
                "averageRecordSize": "119",
                "sizeKey": "2002910",
                "presto_view": "true"
        }
        StorageDescriptor:
          StoredAsSubDirectories: False
          Parameters: {
                  "CrawlerSchemaDeserializerVersion": "1.0",
                  "compressionType": "none",
                  "classification": "csv",
                  "recordCount": "16831",
                  "typeOfData": "file",
                  "CrawlerSchemaSerializerVersion": "1.0",
                  "columnsOrdered": "true",
                  "objectCount": "1",
                  "delimiter": ",",
                  "skip.header.line.count": "1",
                  "averageRecordSize": "119",
                  "sizeKey": "2002910"
          }
          InputFormat: "org.apache.hadoop.mapred.TextInputFormat"
          OutputFormat: "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat"
          Columns:
            - Type: string
              Name: salesperson
            - Type: string
              Name: lead_name
        ViewOriginalText:
          'Fn::Sub':
            - '/* Presto View: ${View} */'
            - View:
                 'Fn::Base64': !sub '{"catalog": "awsdatacatalog",
                                  "schema":"default",
                                  "columns": [ { "name": "salesperson", "type": "varchar" }, { "name": "lead_name", "type": "varchar" }],
                                  "originalSql": "SELECT salesperson AS salesperson, lead_name AS lead_name FROM marketing_qs_1"
                  }'
        Retention: 0
        Name: !Ref SalesPipelineTableName
      DatabaseName: !Ref MarketingAndSalesDatabaseName
      CatalogId: !Ref AWS::AccountId

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation aws-glue aws-cloudformation-custom-resource


    【解决方案1】:

    这些属性应位于StorageDescriptor 下方,而不是ViewOriginalText

              Compressed: False
              Location: !Sub "s3://${DataBucketName}/sales/"
    

    建议在创作模板时尝试使用VSCode 中的CloudFormation Linter 来查看其中一些内联错误:

    [cfn-lint] E3002: Property is an object instead of String at Resources/SalesPipelineTable/Properties/TableInput/ViewOriginalText

    Sub 里面也不需要Base64

    [cfn-lint] W1020: Fn::Sub isn't needed because there are no variables at Resources/SalesPipelineTable/Properties/TableInput/ViewOriginalText/Fn::Sub/1/View/Fn::Base64/Fn::Sub

    【讨论】:

    • 编辑了新代码供您在原帖中参考
    • 感谢@pat 的回复,我已经使用 cfn-lint 解决了这些问题。我面临新问题 E3002 属性应该是字符串类型而不是资源/SalesPipelineTable/Properties/TableInput/ViewOriginalText 的列表。抱歉,我是这些 cloudformation 脚本的新手,所以我找不到此问题的解决方案。提前致谢
    • @John 认为我可能将您与关于 Sub 的额外评论混淆了,因为现在已经从 ViewOriginalText 中删除了太多内容。原来的ViewOriginalText应该没问题
    • 感谢@Pat 的回复。我已经进行了更改并发布在原始帖子中。 cfn-lint 没有显示任何错误,但云形成表示 YAML 格式不正确。你能看看它并弄清楚为什么它会抛出一个错误,在此先感谢!
    猜你喜欢
    • 2021-12-06
    • 1970-01-01
    • 1970-01-01
    • 2020-02-05
    • 2020-06-03
    • 2020-09-20
    • 2019-11-02
    • 2021-04-16
    • 2021-05-31
    相关资源
    最近更新 更多