Skip to content

IAM Role-Based RDS Access

0

As subject, how to connect to an RDS MySQL database using IAM roles in Python applications

2 Answers
5
Accepted Answer
EXPERT
answered a year ago
EXPERT
reviewed a year ago
EXPERT
reviewed a year ago
0

Hey,

Hope you're keeping well.

To connect to an RDS MySQL instance using IAM authentication in Python, first ensure your DB instance has IAM DB authentication enabled and your IAM role or user has the rds-db:connect permission for that DB resource ARN. In your Python code, use boto3 to call generate_db_auth_token with the endpoint, port, username, and AWS region to get a temporary auth token. Pass this token as the password when creating the MySQL connection with a library like PyMySQL or mysqlclient. Make sure the client connects over TLS, as IAM auth requires SSL.

Thanks and regards,
Taz

answered 5 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.