I am trying to implement aws secret manager in java play framework. I followed the steps in this article Getting database credentials from AWS Secrets Manager in Spring Boot to implement it in springboot first which worked perfectly.
Now, I am following the same steps in play framework.
Step 1: I added following dependencies in build.sbt
libraryDependencies ++= Seq(
"com.amazonaws" % "aws-java-sdk" % "1.12.122",
"com.amazonaws.secretsmanager" % "aws-secretsmanager-jdbc" % "1.0.6",
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.12.2"
)
Other relevant dependencies includes:
libraryDependencies ++= Seq(
"mysql" % "mysql-connector-java" % "8.0.21"
)
libraryDependencies ++= Seq(
javaJpa,
"org.hibernate" % "hibernate-core" % "5.4.21.Final", // it is JPA implementation
"javax.validation" % "validation-api" % "2.0.1.Final" // added this because an issue was coming while running
)
Step 2: updated the conf file
Old config (which is working perfectly fine)
play.db {
default = unclassified
}
base_db_url = "jdbc:mysql://{my_rds_endpoint}/"
db_annotations= "?createDatabaseIfNotExist=true"
base_db_user_name= "{rds_user_name}"
base_db_password= "{rds_password}"
db {
unclassified.driver = com.mysql.cj.jdbc.Driver//com.mysql.cj.jdbc.Driver
unclassified.jndiName = UnclassifiedDS
unclassified.url= ${base_db_url}"unclassified_"${serverEnvironment}${db_annotations}
unclassified.username=${base_db_user_name}
unclassified.password=${base_db_password}
}
New config:
play.db {
default = unclassified
}
base_db_url = "jdbc-secretsmanager:mysql://{my-rds-endpoint}/"
db_annotations= "?createDatabaseIfNotExist=true"
base_db_user_name= "{secret-name in secret manager}"
db {
unclassified.driver=com.amazonaws.secretsmanager.sql.AWSSecretsManagerMySQLDriver
unclassified.jndiName = UnclassifiedDS
unclassified.url= ${base_db_url}"unclassified_"${serverEnvironment}${db_annotations}
unclassified.username=${base_db_user_name}
}
But getting the error: Configuration error [Cannot initialize to database] Caused by: java.lang.IllegalArgumentException: dataSource or dataSourceClassName or jdbcUrl is required.
Can anyone help me here?