2 Answers
- Newest
- Most votes
- Most comments
5
Referring this:
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.Connecting.Python.html
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
