AWS Athena部署无服务器框架

时间:2019-03-13 15:42:01

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

有人暗示我如何将CloudFormation的!Ref和!Sub转换为serverless.yml。

resources:
  Resources:
    AthenaCreateDatabaseQuery:
      Type: 'AWS::Athena::NamedQuery'
      Properties:
        Description: Run this query to initialize the Athena database
        QueryString: "CREATE DATABASE IF NOT EXISTS $(self:custom.etlDatabase};"
        Database: ${self:custom.etlDataBase}

  • 在Cloudformation中,QueryString属性以!Sub和 !Ref来访问数据库属性。

感谢基督徒

1 个答案:

答案 0 :(得分:1)

!serverless.com(see this issue on GitHub)当前不支持Sub,但是您可以使用以下插件https://gitlab.com/kabo/serverless-cf-vars

  

每当您希望cloudformation模板具有包含$ {}的字符串时,只需使用#{}即可,它将在cloudformation模板中转换为正确的$ {}(为您插入Fn :: Sub)。部署之前。

或按照建议的here使用自定义变量语法。两者都需要在yaml中使用Fn :: Sub和Fn :: Ref,而不是缩写形式!Sub和!Ref