【问题标题】:Connecting Athena and S3 in same Cloudformation Stack在同一个 Cloudformation 堆栈中连接 Athena 和 S3
【发布时间】:2018-03-17 15:47:42
【问题描述】:

从文档AWS::Athena::NamedQuery 来看,不清楚如何将 Athena 附加到同一堆栈中指定的 S3 存储桶。

如果我不得不从example 中猜测,我想你可以写一个类似的模板,

Resources:
  MyS3Bucket:
    Type: AWS::S3::Bucket
       ... other params ...

  AthenaNamedQuery:
    Type: AWS::Athena::NamedQuery
    Properties:
      Database: "db_name"
      Name: "MostExpensiveWorkflow"
      QueryString: >
                    CREATE EXTERNAL TABLE db_name.test_table 
                    (...) LOCATION s3://.../path/to/folder/

像上面这样的模板可以工作吗?创建堆栈后,表db_name.test_table 是否可用于运行查询?

【问题讨论】:

    标签: amazon-web-services amazon-s3 amazon-cloudformation amazon-athena


    【解决方案1】:

    原来连接 S3 和 Athena 的方式是制作一个 Glue 表!我怎么这么傻!!当然,胶水是您连接事物的方式!

    撇开讽刺不谈,这是一个在使用 AWS::Glue::TableAWS::Glue::Database 时对我有用的模板,

    Resources:
      MyS3Bucket:
        Type: AWS::S3::Bucket
    
      MyGlueDatabase:
        Type: AWS::Glue::Database
        Properties:
          DatabaseInput:
            Name: my-glue-database
            Description: "Glue beats tape"
          CatalogId: !Ref AWS::AccountId
    
      MyGlueTable:
        Type: AWS::Glue::Table
        Properties:
          DatabaseName: !Ref MyGlueDatabase
          CatalogId: !Ref AWS::AccountId
          TableInput:
            Name: my-glue-table
            Parameters: { "classification" : "csv" }
            StorageDescriptor:
              Location:
                Fn::Sub: "s3://${MyS3Bucket}/"
              InputFormat: "org.apache.hadoop.mapred.TextInputFormat"
              OutputFormat: "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat"
              SerdeInfo:
                Parameters: { "separatorChar" : "," }
                SerializationLibrary: "org.apache.hadoop.hive.serde2.OpenCSVSerde"
              StoredAsSubDirectories: false
              Columns:
                - Name: column0
                  Type: string
                - Name: column1
                  Type: string
    

    在此之后,数据库和表在 AWS Athena 控制台中!

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-21
    • 1970-01-01
    • 1970-01-01
    • 2020-09-15
    • 2022-06-10
    • 2021-02-21
    相关资源
    最近更新 更多