Area: Ingestion
Sub-Area: Authentication
Applies to: OSS + Cloud
Issue
You want DataHub ingestion to use AWS IAM authentication for Aurora PostgreSQL, Aurora MySQL or MSK Kafka, or IAM authentication fails or the recipe is rejected.
You Might Be Asking
- Which keys turn on IAM authentication for Aurora PostgreSQL or MySQL?
- Which IAM action does the database user need?
- How do I use MSK IAM with the Kafka source?
- Why does my recipe fail validation?
Cause
The postgres, mysql and kafka sources reject keys they don't define, so a recipe with an unknown key fails validation. These keys are common mistakes:
-
use_iam_authand a top-levelaws_regionon the postgres or mysql source. Neither exists. -
consumer_configat the top level of the kafka source. It belongs underconnection. - Java client settings for MSK (
sasl.mechanism: AWS_MSK_IAM,sasl.jaas.config,sasl.client.callback.handler.class). Use the built-in OAUTHBEARER callback described below instead. - The IAM action
rds:connect. The action for RDS IAM database login isrds-db:connect.
For the Kafka source, Test Connection ignores unknown top-level keys. A passing Test Connection doesn't prove the top-level keys are valid. Full ingestion validates them.
Solution
Aurora PostgreSQL and Aurora MySQL
Set auth_mode: AWS_IAM (the default is PASSWORD). Set username to the database user that is enabled for IAM. Include the port in host_port. Put the region and credentials under aws_config. See the Postgres config details and the MySQL RDS IAM section.
source:
type: postgres # or mysql
config:
host_port: "<your-aurora-endpoint>:<port>"
username: "your_iam_db_user"
auth_mode: AWS_IAM
aws_config:
aws_region: "us-east-1"
# database is optional. See the note below.
If you leave out aws_config, DataHub uses the default boto3 credential chain. It reads the region from AWS_DEFAULT_REGION or AWS_REGION, ~/.aws/config or IAM role metadata.
Notes:
-
databaseis optional on both sources. On Postgres, if you leave it out, DataHub ingests all databases. It finds them by connecting toinitial_database(defaultpostgres). Setdatabaseto limit ingestion to one database. IAM authentication doesn't need it. - Without
username, ingestion fails with "username is required for RDS IAM authentication." - Without a port in
host_port, ingestion fails with "Port must be specified for RDS IAM authentication". - DataHub fetches a fresh token for each connection and always requires TLS.
- The IAM policy for the identity that runs ingestion must allow
rds-db:connect. Don't userds:connect. The MySQL docs describe this policy.
MSK / Kafka
Put all connection settings under connection. Use the built-in OAUTHBEARER callback for MSK IAM. See the Kafka OAuth callback docs.
source:
type: kafka
config:
connection:
bootstrap: "<your MSK bootstrap broker>"
schema_registry_url: "https://schema-registry.company.com"
consumer_config:
security.protocol: SASL_SSL
sasl.mechanism: OAUTHBEARER
oauth_cb: "datahub_actions.utils.kafka_msk_iam:oauth_cb"
-
oauth_cbis a<python-module>:<function-name>string that DataHub resolves to a callable. - The callback needs the
acryl-datahub-actionspackage in the environment that runs ingestion. The docs require version 1.3.1.2 or later. In Cloud UI ingestion, add it in the Extra Pip Libraries field under Advanced Settings in the source's Connection Details step. Make sure the package is installed. - The callback signs tokens for the region in the
AWS_REGIONenvironment variable, thenAWS_DEFAULT_REGION. If neither is set, it usesus-east-1. It doesn't read a region from the recipe. If your cluster isn't inus-east-1, setAWS_REGIONin the ingestion environment.
Permissions
- The identity that runs ingestion needs the IAM permissions for the service. With a Remote Executor, attach the IAM role to the executor. You manage that role.
- For Aurora, grant
rds-db:connect.