Skip to content

Commit 3621071

Browse files
committed
chore: add required permissions to multiaz IAM user
1 parent 227ced5 commit 3621071

File tree

5 files changed

+8
-4
lines changed

5 files changed

+8
-4
lines changed

docs/using-the-jdbc-driver/using-plugins/UsingTheIamAuthenticationPlugin.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ IAM database authentication use is limited to certain database engines. For more
3636
3. [Create a database account](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.DBAccounts.html) using AWS IAM database authentication. This will be the user specified in the connection string or connection properties.
3737
1. Connect to your database of choice using primary logins.
3838
1. For a MySQL database, use the following command to create a new user:<br>
39-
`CREATE USER example_user_name IDENTIFIED WITH AWSAuthenticationPlugin AS 'RDS';`
39+
`CREATE USER example_user_name IDENTIFIED WITH AWSAuthenticationPlugin AS 'RDS';`<br>
40+
You might also need to grant extra permissions to the IAM user when connecting to RDS Multi-AZ deployments:<br>
41+
```GRANT REPLICATION CLIENT ON *.* TO example_user_name@`%`;```
4042
2. For a PostgreSQL database, use the following command to create a new user:<br>
4143
`CREATE USER db_userx;
4244
GRANT rds_iam TO db_userx;`

wrapper/src/main/java/software/amazon/jdbc/hostlistprovider/RdsHostListProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ protected List<HostSpec> queryForTopology(final Connection conn) throws SQLExcep
370370
final ResultSet resultSet = stmt.executeQuery(this.topologyQuery)) {
371371
return processQueryResults(resultSet);
372372
} catch (final SQLSyntaxErrorException e) {
373-
throw new SQLException(Messages.get("RdsHostListProvider.invalidQuery"), e);
373+
throw new SQLException(Messages.get("RdsHostListProvider.invalidQuery", new Object[] { e.getMessage() }), e);
374374
} finally {
375375
if (networkTimeout == 0 && !conn.isClosed()) {
376376
conn.setNetworkTimeout(networkTimeoutExecutor, networkTimeout);

wrapper/src/main/java/software/amazon/jdbc/hostlistprovider/RdsMultiAzDbClusterListProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected List<HostSpec> queryForTopology(final Connection conn) throws SQLExcep
9191
final ResultSet topologyResultSet = stmt.executeQuery(this.topologyQuery);
9292
return processTopologyQueryResults(topologyResultSet, writerNodeId);
9393
} catch (final SQLSyntaxErrorException e) {
94-
throw new SQLException(Messages.get("RdsHostListProvider.invalidQuery"), e);
94+
throw new SQLException(Messages.get("RdsHostListProvider.invalidQueryMultiAz", new Object[] { e.getMessage() }), e);
9595
} finally {
9696
if (networkTimeout == 0 && !conn.isClosed()) {
9797
conn.setNetworkTimeout(networkTimeoutExecutor, networkTimeout);

wrapper/src/main/resources/aws_advanced_jdbc_wrapper_messages.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ RdsHostListProvider.invalidPattern=Invalid value for the 'clusterInstanceHostPat
3737
RdsHostListProvider.invalidTopology=The topology query returned an invalid topology - no writer instance detected.
3838
RdsHostListProvider.suggestedClusterId=ClusterId ''{0}'' is suggested for url ''{1}''.
3939
RdsHostListProvider.parsedListEmpty=Can''t parse connection string: ''{0}''
40-
RdsHostListProvider.invalidQuery=Error obtaining host list. Provided database might not be an Aurora Db cluster
40+
RdsHostListProvider.invalidQuery=Error obtaining host list. Provided database might not be an Aurora Db cluster: ''{0}''
41+
RdsHostListProvider.invalidQueryMultiAz=Error obtaining host list. Provided database might not be an RDS Multi-AZ Db cluster: ''{0}''
4142
RdsHostListProvider.errorGettingHostRole=An error occurred while obtaining the connected host's role. This could occur if the connection is broken or if you are not connected to an Aurora database.
4243
RdsHostListProvider.errorIdentifyConnection=An error occurred while obtaining the connection's host ID.
4344
RdsHostListProvider.errorGettingNetworkTimeout=An error occurred while getting the connection network timeout: {0}

wrapper/src/test/java/integration/util/AuroraTestUtility.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,6 +1902,7 @@ public void addAuroraAwsIamUser(
19021902
} else {
19031903
stmt.execute("GRANT ALL PRIVILEGES ON `%`.* TO '" + dbUser + "'@'%';");
19041904
}
1905+
stmt.execute("GRANT REPLICATION CLIENT ON *.* TO '" + dbUser + "'@'%';");
19051906

19061907
// BG switchover status needs it.
19071908
stmt.execute("GRANT SELECT ON mysql.* TO '" + dbUser + "'@'%';");

0 commit comments

Comments
 (0)