在 CloudFormation 上使用 JdbcTargets 指定 Glue::Crawler

vil*_*asv 3 amazon-web-services aws-cloudformation aws-glue

我正在尝试设置 AWS Glue 以使用 CloudFormation 从 RDS Postgres 读取。为此,我需要使用 JdbcTarget 选项创建一个爬虫。(或者我没有?)

  Records:
    Type: 'AWS::Glue::Crawler'
    Properties:
      DatabaseName: transact
      Targets:
        JdbcTargets:
          - Path: "jdbc:postgresql://host:5432/database"
      Role: !Ref ETLAgent
Run Code Online (Sandbox Code Playgroud)

但是在 CloudFormation 上创建堆栈将失败:

CREATE_FAILED | AWS::Glue::Crawler | Records | Connection name cannot be equal to null or empty. (Service: AWSGlue; Status Code: 400; Error Code: InvalidInputException;

即使文档说:

连接名称

用于 JDBC 目标的连接的名称。

要求:否

使用 CloudFormation 的正确 AWS Glue 设置是什么,可以让我从 RDS 读取?

bot*_*que 5

您确实缺少该ConnectionName属性,该属性应该带有您缺少的连接资源的名称。Path您设置的属性用于选择要爬网的架构/表(dbname/%/%包括所有)。有关详细信息,请参阅Crawler JDBCTarget 上的 CloudFormation 文档)。

你的模板应该看起来像

  MyDbConnection:
    Type: "AWS::Glue::Connection"
    Properties:
      CatalogId: !Ref 'AWS::AccountId'
      ConnectionInput:
        Description: "JDBC Connection to my RDS DB"
        PhysicalConnectionRequirements:
          AvailabilityZone: "eu-central-1a"
          SecurityGroupIdList:
           - my-sec-group-id
          SubnetId: my-subnet-id
        ConnectionType: "JDBC"
        ConnectionProperties:
          "JDBC_CONNECTION_URL": "jdbc:postgresql://host:5432/database"
          "USERNAME": "my-db-username"
          "PASSWORD": "my-password"
  Records:
    Type: 'AWS::Glue::Crawler'
    Properties:
      DatabaseName: transact
      Targets:
        JdbcTargets:
          - ConnectionName: !Ref MyDbConnection
            Path: "database/%/%"
      Role: !Ref ETLAgent
Run Code Online (Sandbox Code Playgroud)