Search code examples
aws-cloudformationaws-glue

How to set Driver Path and Driver Class Name for a Glue Connection using CloudFormation Template?


I am using a JSON CloudFormation template to create a Glue Connection. I need to set the "Driver Path" and "Driver Class Name". It's easy to set these properties on the AWS Console, but I can't figure out how to set these properties in the CloudFormation template. I assume they are somehow specified in the ConnectionProperties but the documentation does not specify the property names.

What I tried:

  • Read documentation
  • Searched online
  • Asked Amazon Q
  • Tried several educated guesses

Still no luck. Here is my latest attempt (based on an answer from Amazon Q):

"GlueDatabaseConnection": {
  "Type": "AWS::Glue::Connection",
  "Properties": {
    "CatalogId": {
      "Ref": "AWS::AccountId"
    },
    "ConnectionInput": {
      "Name": "my-connection-name",
      "ConnectionType": "JDBC",
      "ConnectionProperties": {
        "JDBC_CONNECTION_URL": "my-jdbc-url",
        "SECRET_ID": "my-secret-id",
        "JDBC_ENFORCE_SSL": "false",
        "JDBC_DRIVER_S3_PATH": "path-to-driver",
        "DRIVER": "org.postgresql.Driver"
      },
      "PhysicalConnectionRequirements": {
        "SubnetId": "my-subnet-id",
        "SecurityGroupIdList": [
          "my-security-group-id"
        ]
      }
    }
  }
}

Solution

  • The correct properties are JDBC_DRIVER_JAR_URI and JDBC_DRIVER_CLASS_NAME.

    Full example:

    "GlueDatabaseConnection": {
      "Type": "AWS::Glue::Connection",
      "Properties": {
        "CatalogId": {
          "Ref": "AWS::AccountId"
        },
        "ConnectionInput": {
          "Name": "my-connection-name",
          "ConnectionType": "JDBC",
          "ConnectionProperties": {
            "JDBC_CONNECTION_URL": "my-jdbc-url",
            "SECRET_ID": "my-secret-id",
            "JDBC_ENFORCE_SSL": "false",
            "JDBC_DRIVER_JAR_URI": "path-to-driver",
            "JDBC_DRIVER_CLASS_NAME": "org.postgresql.Driver"
          },
          "PhysicalConnectionRequirements": {
            "SubnetId": "my-subnet-id",
            "SecurityGroupIdList": [
              "my-security-group-id"
            ]
          }
        }
      }
    }
    

    I figured this out by inspecting the HTTP request that is sent when I set these properties on the AWS web console.