1

從文檔AWS::Athena::NamedQuery,不清楚如何將雅典娜附加到同一個堆棧中指定的S3存儲桶。將雅典娜和S3連接在同一個Cloudformation棧中

如果我不得不從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可用於在上運行查詢嗎?

回答

1

原來,你連接S3和雅典娜的方式是做一個膠水錶!我多麼愚蠢!當然膠水是你如何連接的東西!

除了諷刺以外,這是一個模板,使用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控制檯雅典娜!