I’m attempting to combine IAM Database Authentication(https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.html) with Airflow’s sql_alchemy_conn_cmd(https://airflow.apache.org/howto/set-config.html#) with the a connect shell script to try and secure a connection.
connect.sh
#!/bin/bash
token=`aws rds generate-db-auth-token --hostname an_rds_endpoint --port 3306 --region us-east-1 --username airflow`
url=“mysql://airflow:'$token'@an_rds_endpoint/airflow”
sed "s/%/%%/g" <<< "$url”
I currently have an EC2 instance with the mysql dev tools connecting successfully to an RDS MySQL database via IAM DB Authentication using these steps(https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.Connecting.AWSCLI.html)
The trouble I am having is that I am getting the following error:
super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (OperationalError) (1045, "Access denied for user ‘airflow’@‘ip_address_of_ec2_instance’ (using password: YES)")
…after I attempt to run airflow initdb with my sql_alchemy_conn_cmd = connect.sh in my airflow.cfg file.
My initial guess is that the encoding on the “insanely verbose token AWS generates” is the issue but I was wondering if anyone had gone down this road yet and can help.
This is part of a token that’s generated for reference.
rdsmysql.cdgmuqiadpid.us-west-2.rds.amazonaws.com:3306/?Action=connect&DBUser=jane_doe&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=900...