Secret credentials not passed when using Glue Custom Connector

0

I created a custom Glue Connector for a JDBC resource I want to connect to in an ETL job. I created a connection for this connector referencing the credential secret. When I attempt to connect to to the data source using this connection using this code:

dyf = glue_context.create_dynamic_frame.from_options(
    connection_type="custom.jdbc",
    connection_options={
        "dbTable": "MY_TABLE",
        "connectionName": "connector-connection",
        "useConnectionProperties": "true",
        # "user": conf["user"],
        # "password": conf["password"],
    },
    transformation_ctx="dyf_1709299053",
)

I get the following error from the driver: Insufficient information to log on the database. Missing parameters are: USER PASSWORD. Passing the credentials in the connection_options (uncommenting the above lines) does not work either.

How can I pass in these credentials from the connection? Do I need to change some setting in my connector config?

Creating a connection in the following manner works, but I would prefer the first approach as it seems a bit simpler and I like not having to pull the credential parameters into the job.

conf = glue_context.extract_jdbc_conf('jdbc-connection')

connection_options = {
    "url": conf["fullUrl"],
    "className": "driver name",
    "user": conf["user"],
    "password": conf["password"],
    "dbTable": "MY_TABLE",
}

connection_dyf = glue_context.create_dynamic_frame.from_options(
    connection_type="custom.jdbc", connection_options=connection_options
)
Vince
已提問 2 個月前檢視次數 88 次
2 個答案
0

I don't think in the first case "useConnectionProperties" is doing anything since that is for JDBC connections (not custom), the connection name should be enough and I think that is that is what is overriding the user/password when you pass it. I suspect there is something wrong with the secret you have configured (make sure the key in the secret is "username" and not "user".

profile pictureAWS
專家
已回答 2 個月前
  • The secret key is username not user. I think is is configured correctly since extract_jdbc_conf returns the correct values.

    I tried the connection without useConnectionProperties and the result was the same.

0

I found this post which mentions setting user=${username},password=${password} placeholders as part of the URL base in the connector. Adding this configuration fixed the issue I was facing.

This is mentioned in this AWS doc, but it was unclear to me how to use these. For instance, I initially tried to use ${secretKey} but I am apparently not using this as intended.

Final tip, after updating the connector with the credential placeholders, you need to update the connection by selecting default from the Connection credential type dropdown. This refreshes the connection with the connector updates.

Vince
已回答 2 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南