$npx -y skills add giuseppe-trisciuoglio/developer-kit --skill aws-sdk-java-v2-rdsProvides AWS RDS (Relational Database Service) management patterns using AWS SDK for Java 2.x. Use when creating, modifying, monitoring, or managing Amazon RDS database instances, snapshots, parameter groups, and configurations.
| 1 | # AWS SDK for Java v2 - RDS Management |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | This skill provides comprehensive guidance for working with Amazon RDS (Relational Database Service) using the AWS SDK for Java 2.x, covering database instance management, snapshots, parameter groups, and RDS operations. |
| 6 | |
| 7 | ## When to Use |
| 8 | |
| 9 | - Creating, modifying, or deleting RDS database instances |
| 10 | - Managing DB snapshots, parameter groups, and configurations |
| 11 | - Setting up Multi-AZ deployments and automated backups |
| 12 | - Connecting Lambda functions to RDS databases |
| 13 | - Monitoring instance status and performance |
| 14 | |
| 15 | ## Instructions |
| 16 | |
| 17 | Follow these steps to work with Amazon RDS: |
| 18 | |
| 19 | 1. **Add Dependencies** - Include AWS RDS SDK dependency and database drivers |
| 20 | 2. **Create RDS Client** - Instantiate RdsClient with proper region and credentials |
| 21 | 3. **Create DB Instance** - Use createDBInstance() with appropriate configuration |
| 22 | 4. **Configure Security** - Set up VPC security groups and encryption |
| 23 | 5. **Set Up Backups** - Configure automated backup windows and retention |
| 24 | 6. **Monitor Status** - Use describeDBInstances() to check instance state |
| 25 | 7. **Create Snapshots** - Take manual snapshots before major changes |
| 26 | 8. **Handle Failover** - Configure Multi-AZ for high availability |
| 27 | |
| 28 | ## Getting Started |
| 29 | |
| 30 | ### RDS Client Setup |
| 31 | |
| 32 | The `RdsClient` is the main entry point for interacting with Amazon RDS. |
| 33 | |
| 34 | **Basic Client Creation:** |
| 35 | ```java |
| 36 | import software.amazon.awssdk.regions.Region; |
| 37 | import software.amazon.awssdk.services.rds.RdsClient; |
| 38 | |
| 39 | RdsClient rdsClient = RdsClient.builder() |
| 40 | .region(Region.US_EAST_1) |
| 41 | .build(); |
| 42 | |
| 43 | // Use client |
| 44 | describeInstances(rdsClient); |
| 45 | |
| 46 | // Always close the client |
| 47 | rdsClient.close(); |
| 48 | ``` |
| 49 | |
| 50 | **Client with Custom Configuration:** |
| 51 | ```java |
| 52 | import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; |
| 53 | import software.amazon.awssdk.http.apache.ApacheHttpClient; |
| 54 | |
| 55 | RdsClient rdsClient = RdsClient.builder() |
| 56 | .region(Region.US_WEST_2) |
| 57 | .credentialsProvider(ProfileCredentialsProvider.create("myprofile")) |
| 58 | .httpClient(ApacheHttpClient.builder() |
| 59 | .connectionTimeout(Duration.ofSeconds(30)) |
| 60 | .socketTimeout(Duration.ofSeconds(60)) |
| 61 | .build()) |
| 62 | .build(); |
| 63 | ``` |
| 64 | |
| 65 | ### Describing DB Instances |
| 66 | |
| 67 | ```java |
| 68 | DescribeDbInstancesResponse response = rdsClient.describeDBInstances(); |
| 69 | for (DBInstance instance : response.dbInstances()) { |
| 70 | System.out.println(instance.dbInstanceArn() + " - " + instance.dbInstanceStatus()); |
| 71 | } |
| 72 | ``` |
| 73 | |
| 74 | ## Key Operations |
| 75 | |
| 76 | ### Creating DB Instances |
| 77 | |
| 78 | ```java |
| 79 | CreateDbInstanceRequest request = CreateDbInstanceRequest.builder() |
| 80 | .dbInstanceIdentifier(dbInstanceIdentifier) |
| 81 | .dbName(dbName) |
| 82 | .engine("postgres") |
| 83 | .engineVersion("15.4") |
| 84 | .dbInstanceClass("db.t3.micro") |
| 85 | .allocatedStorage(20) |
| 86 | .masterUsername(masterUsername) |
| 87 | .masterUserPassword(masterPassword) |
| 88 | .publiclyAccessible(false) |
| 89 | .build(); |
| 90 | |
| 91 | CreateDbInstanceResponse response = rdsClient.createDBInstance(request); |
| 92 | |
| 93 | // VALIDATION CHECKPOINT: Wait for instance to be available |
| 94 | rdsClient.waiter().waitUntilDBInstanceAvailable( |
| 95 | DescribeDbInstancesRequest.builder().dbInstanceIdentifier(dbInstanceIdentifier).build() |
| 96 | ); |
| 97 | System.out.println("Instance " + dbInstanceIdentifier + " is available!"); |
| 98 | ``` |
| 99 | |
| 100 | ### Managing DB Parameter Groups |
| 101 | |
| 102 | ```java |
| 103 | CreateDbParameterGroupRequest request = CreateDbParameterGroupRequest.builder() |
| 104 | .dbParameterGroupName(groupName) |
| 105 | .dbParameterGroupFamily("postgres15") |
| 106 | .description(description) |
| 107 | .build(); |
| 108 | rdsClient.createDBParameterGroup(request); |
| 109 | ``` |
| 110 | |
| 111 | ### Managing DB Snapshots |
| 112 | |
| 113 | ```java |
| 114 | CreateDbSnapshotRequest request = CreateDbSnapshotRequest.builder() |
| 115 | .dbInstanceIdentifier(dbInstanceIdentifier) |
| 116 | .dbSnapshotIdentifier(snapshotIdentifier) |
| 117 | .build(); |
| 118 | CreateDbSnapshotResponse response = rdsClient.createDBSnapshot(request); |
| 119 | ``` |
| 120 | |
| 121 | ## Integration Patterns |
| 122 | |
| 123 | ### Spring Boot Integration |
| 124 | |
| 125 | Refer to [references/spring-boot-integration.md](references/spring-boot-integration.md) for complete Spring Boot integration examples including: |
| 126 | |
| 127 | - Spring Boot configuration with application properties |
| 128 | - RDS client bean configuration |
| 129 | - Service layer implementation |
| 130 | - REST controller design |
| 131 | - Exception handling |
| 132 | - Testing strategies |
| 133 | |
| 134 | ### Lambda Integration |
| 135 | |
| 136 | Refer to [references/lambda-integration.md](references/lambda-integration.md) for Lambda integration examples including: |
| 137 | |
| 138 | - Traditional Lambda + RDS connections |
| 139 | - Lambda with connection pooling |
| 140 | - Using AWS Secrets Manager for credentials |
| 141 | - Lambda with AWS SDK for RDS management |
| 142 | - Security configuration and best practices |
| 143 | |
| 144 | ## Advanced Operations |
| 145 | |
| 146 | ### Modifying DB Instances |
| 147 | |
| 148 | ```java |
| 149 | ModifyDbInstanceRequest request = ModifyDbInstanceRequest.builder() |
| 150 | .dbInstanceIdentifier(db |