Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions,
see Getting Started with Amazon Web Services in China
(PDF).
Modify an Amazon RDS DB instance using an Amazon SDK
The following code examples show how to modify an Amazon RDS DB instance.
- Java
-
- SDK for Java 2.x
-
public static void updateIntance(RdsClient rdsClient, String dbInstanceIdentifier, String masterUserPassword) {
try {
// For a demo - modify the DB instance by modifying the master password.
ModifyDbInstanceRequest modifyDbInstanceRequest = ModifyDbInstanceRequest.builder()
.dbInstanceIdentifier(dbInstanceIdentifier)
.publiclyAccessible(true)
.masterUserPassword(masterUserPassword)
.build();
ModifyDbInstanceResponse instanceResponse = rdsClient.modifyDBInstance(modifyDbInstanceRequest);
System.out.print("The ARN of the modified database is: " +instanceResponse.dbInstance().dbInstanceArn());
} catch (RdsException e) {
System.out.println(e.getLocalizedMessage());
System.exit(1);
}
}
- Kotlin
-
- SDK for Kotlin
-
This is prerelease documentation for a feature in preview release. It is subject to change.
suspend fun updateIntance(dbInstanceIdentifierVal: String?, masterUserPasswordVal: String?) {
val request = ModifyDbInstanceRequest {
dbInstanceIdentifier = dbInstanceIdentifierVal
publiclyAccessible = true
masterUserPassword = masterUserPasswordVal
}
RdsClient { region = "us-west-2" }.use { rdsClient ->
val instanceResponse = rdsClient.modifyDbInstance(request)
println("The ARN of the modified database is ${instanceResponse.dbInstance?.dbInstanceArn}")
}
}
For a complete list of Amazon SDK developer guides and code examples, see
Using this service with an Amazon SDK.
This topic also includes information about getting started and details about previous SDK versions.