aws-doc-sdk-examples
aws-doc-sdk-examples copied to clipboard
Epic: RDS Instances MVP
The RDS guides are divided into two feature groups: RDS, which is focused on instances, and Aurora, which is focused on clusters. The APIs for both of these features are mixed together in the same RDS service client.
This epic is about the RDS instance APIs. The RDS guide is here.
Service actions
Service actions can either be pulled out as individual functions or can be incorporated into the scenario, but each service action must be included as an excerpt in the SOS output.
RDS client:
DescribeDbParameterGroups CreateDbParameterGroup ModifyDbParameterGroup DeleteDbParameterGroup DescribeDbEngineVersions DescribeDbParameters DescribeOrderableDbInstanceOptions DescribeDbInstances CreateDbInstance DeleteDbInstance CreateDbSnapshot DescribeDbSnapshots
Scenario
A scenario runs at a command prompt and prints output to the user on the result of each service action. A scenario can run in one of two ways: straight through, printing out progress as it goes, or as an interactive question/answer script.
Get started with RDS instances
- Get available engine families for RDS MySql. rds.DescribeDbEngineVersions(Engine='mysql') and build a set of the 'DBParameterGroupFamily' field values. I get {mysql5.7, mysql8.0}.
- Select an engine family and create a custom DB parameter group. rds.CreateDbParameterGroup(DBParameterGroupFamily='mysql8.0')
- Get the parameter group. rds.DescribeDbParameterGroups
- Get parameters in the group. This is a long list so you will have to paginate. Find the auto_increment_offset and auto_increment_increment parameters (by ParameterName). rds.DescribeDbParameters
- Parse the ParameterName, Description, and AllowedValues values and display them.
- Modify both the auto_increment_offset and auto_increment_increment parameters in one call in the custom parameter group. Set their ParameterValue fields to a new allowable value. rds.ModifyDbParameterGroup.
- Get and display the updated parameters. Specify Source of 'user' to get just the modified parameters. rds.DescribeDbParameters(Source='user')
- Get a list of allowed engine versions. rds.DescribeDbEngineVersions(Engine='mysql', DBParameterGroupFamily=<the family used to create your parameter group in step 2>)
- Get a list of micro instance classes available for the selected engine and engine version. rds.DescribeOrderableDbInstanceOptions(Engine='mysql', EngineVersion=[selected engine version]), then filter the list to a set that includes 'micro'. I get: {db.t2.micro, db.t3.micro, db.t4g.micro}.
- Create an RDS database instance that contains a MySql database and uses the parameter group you created.
self.rds_client.create_db_instance(
DBName=db_name,
DBInstanceIdentifier=instance_id,
DBParameterGroupName=parameter_group_name,
Engine=db_engine,
EngineVersion=db_engine_version,
DBInstanceClass=instance_class,
StorageType='standard',
AllocatedStorage=5,
MasterUsername=admin_name,
MasterUserPassword=admin_password)
- Wait for DB instance to be ready. Call rds.DescribeDbInstances and check for DBInstanceStatus == 'available'. (This can take more than 10 mins)
- Display the connection string that can be used to connect a 'mysql' shell to the database. In Python:
print(f"\n\tmysql -h {db_inst['Endpoint']['Address']} -P {db_inst['Endpoint']['Port']} "
f"-u {db_inst['MasterUsername']} -p\n")
- Create a snapshot of the DB instance. rds.CreateDbSnapshot.
- Wait for snapshot to create. rds.DescribeDbSnapshots until Status == 'available.
- Delete the DB instance. rds.DeleteDbInstance
- Wait for the instance to delete. rds.DescribeDbInstances until it returns not found.
- Delete the parameter group. rds.DeleteDbParameterGroup.
Metadata
In rds_metadata:
rds_DescribeDbParameterGroups rds_CreateDbParameterGroup rds_ModifyDbParameterGroup rds_DeleteDbParameterGroup rds_DescribeDbEngineVersions rds_DescribeDbParameters rds_DescribeOrderableDbInstanceOptions rds_DescribeDbInstances rds_CreateDbInstance rds_DeleteDbInstance rds_CreateDbSnapshot rds_DescribeDbSnapshots rds_Scenario_GetStartedInstances
SDKs
- [x] #3615
- [x] #4245
- [x] #4850
- [x] #3616
- [ ] JavaScript RDS MVP
- [x] #3617
- [x] #3405
- [ ] PHP RDS MVP
- [ ] Ruby RDS MVP
- [ ] Rust RDS MVP
- [ ] Swift RDS MVP
Exit criteria:
Runnable scenario code. Service action code (may be same as scenario code). Integration or unit tests. Scenario and API examples tagged for SOS. README
Rust in #5476