My Query is very similar to this slack post - Accessing AWS RDS using IAM Authentication and Spring JDBC (DataSource and JdbcTemplate)
I tried the following: Add the following dependencies:
runtimeOnly 'software.aws.rds:aws-mysql-jdbc:1.1.6'
runtimeOnly 'software.amazon.awssdk:rds:2.20.57'
Add the following to application.yml:
spring:
datasource:
jdbc-url: jdbc:mysql:aws://yourdbcluster-xxxx.cluster-xxxx.your-region.rds.amazonaws.com:3306/yourdb?useAwsIam=true
username: iam_username
#password: dont-need-this
driver-class-name: software.aws.rds.jdbc.mysql.Driver
The driver uses the AWS default credentials provider chain so make sure you have credentials with policy allowing IAM DB access available wherever you are running your app -
To check if the application running on Amazon ECS has the necessary AWS credentials with a policy allowing IAM DB access, I followed these steps:
aws iam list-attached-role-policies --role-name ROLE_NAME
aws iam get-policy-version --policy-arn POLICY_ARN --version-id v1
In the policy details, verified there is a statement allowing the rds-db:connect action.
But still the application is throwing : Access denied for the user and not able to create the bean liquidbase
.
Is there any other changes required? Please suggest