-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Describe the bug
Hi team,
I've been experimenting with Aurora DSQL but I couldn't produce a JDBC/AwsWrapperDataSource/Hikari compatible implementation yet.
I believe it is an important gap to cover, since a JDBC connector is a basic need for JVM-based applications that would be a significant part of the market for Aurora. For example, we are exploring migrating a few use cases from Aurora, which are currently Hikari based.
An Aurora compatible example similar to this one would go a long way: https://github.com/aws/aws-advanced-jdbc-wrapper/blob/main/examples/AWSDriverExample/src/main/java/software/amazon/DatasourceExample.java#L31
Expected Behavior
org.postgresql.util.PSQLException: FATAL: unable to accept connection, access denied Detail: Session Id: <session-id>
Current Behavior
Doesn't connect after providing some based information (similar to what would be needed for Aurora)
Reproduction Steps
@Override
override fun startUp() {
AwsCredentialsManager.setCustomHandler(
AwsCredentialsProviderHandler { hostSpec: HostSpec?, props: Properties? ->
return@AwsCredentialsProviderHandler CandidateRelationshipMatcherApplicationModule.getCredentialsProvider(config)
},
)
dataSource = AwsWrapperDataSource()
dataSource.setJdbcProtocol("jdbc:postgresql:")
dataSource.setTargetDataSourceClassName("org.postgresql.ds.PGSimpleDataSource")
dataSource.setServerName(config.dbClusterEndpoint)
dataSource.setDatabase(config.dbName)
dataSource.setServerPort("5432")
val wrapperDataSourceProperties = Properties().apply {
setProperty("wrapperLoggerLevel", "ALL")
setProperty("useIamAuth", "true")
setProperty("iamHost", config.dbClusterEndpoint)
setProperty("iamPort", "5432")
setProperty("iamRegion", config.awsRegion)
setProperty("iamUser", config.dbIamUser)
setProperty(PropertyDefinition.PLUGINS.name, "iam")
setProperty(PropertyDefinition.USER.name, config.dbIamUser)
}
dataSource.setTargetDataSourceProperties(wrapperDataSourceProperties)
try {
dataSource.getConnection().use { conn ->
conn.createStatement().use { statement ->
statement.executeQuery("select * from entity_lookup limit 1;").use { result ->
println("PostgresAWSRoleService: $result")
}
}
}
} catch (e: Exception) {
System.err.println("PostgresAWSRoleService: Failed to establish initial database connection: ${e.message}")
throw e // Re-throw to indicate startup failure to AbstractIdleService
}
println("PostgresAWSRoleService: Service started. JDBI object is ready for use.")
}
// We are certain this one works, I am using the same configuration and keys to access Amazon Keyspaces
fun getCredentialsProvider(config: AWSPostgresConfig): AwsCredentialsProvider {
val baseProvider = StaticCredentialsProvider.create(
AwsBasicCredentials.create(config.accessKeyId, config.secretAccessKey),
)
return StsAssumeRoleCredentialsProvider.builder()
.asyncCredentialUpdateEnabled(true)
.refreshRequest(
AssumeRoleRequest.builder()
.roleArn("arn:aws:iam::<account-id>:role/entity-platform")
.roleSessionName("entity-platform-session-${System.currentTimeMillis()}")
.build(),
)
.stsClient(
StsClient.builder()
.credentialsProvider(baseProvider)
.region(Region.of(config.awsRegion))
.build(),
)
.build()
}
Possible Solution
Provide a JDBC compatible example for Aurora
Additional Information/Context
No response
Environment details (Version of the language and/or framework, OS environment)
OpenJDK Corretto-21.0.5.11.1, Mac Sequoia (15.5 (24F74)), aws-advanced-jdbc-wrapper 2.6.0