AWS AmazonRDS documentation change
Summary
Added Swift SDK code example demonstrating RDS instance lifecycle management including parameter group configuration, instance creation, snapshot handling, and cleanup
Security assessment
The change adds a general usage example without addressing specific security vulnerabilities or introducing new security documentation. While it includes database credentials handling, this is standard API usage rather than security guidance. No evidence of patching vulnerabilities or addressing security incidents.
Diff
diff --git a/AmazonRDS/latest/UserGuide/example_rds_Scenario_GetStartedInstances_section.md b/AmazonRDS/latest/UserGuide/example_rds_Scenario_GetStartedInstances_section.md index fb6cc29f0..78fd3b905 100644 --- a//AmazonRDS/latest/UserGuide/example_rds_Scenario_GetStartedInstances_section.md +++ b//AmazonRDS/latest/UserGuide/example_rds_Scenario_GetStartedInstances_section.md @@ -4010,0 +4011,886 @@ Define functions that are called by the scenario to manage Amazon RDS actions. +Swift + + +**SDK for Swift** + + +###### Note + +There's more on GitHub. Find the complete example and learn how to set up and run in the [AWS Code Examples Repository](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/swift/example_code/rds#code-examples). + +The `Package.swift` file. + + + // swift-tools-version: 5.9 + // + // The swift-tools-version declares the minimum version of Swift required to + // build this package. + + import PackageDescription + + let package = Package( + name: "rds-scenario", + // Let Xcode know the minimum Apple platforms supported. + platforms: [ + .macOS(.v13), + .iOS(.v15) + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + .package( + url: "https://github.com/awslabs/aws-sdk-swift", + from: "1.4.0"), + .package( + url: "https://github.com/apple/swift-argument-parser.git", + branch: "main" + ) + ], + targets: [ + // Targets are the basic building blocks of a package, defining a module or a test suite. + // Targets can depend on other targets in this package and products + // from dependencies. + .executableTarget( + name: "rds-scenario", + dependencies: [ + .product(name: "AWSRDS", package: "aws-sdk-swift"), + .product(name: "ArgumentParser", package: "swift-argument-parser") + ], + path: "Sources") + + ] + ) + + + +The Swift code file, `entry.swift`. + + + // An example that shows how to use the AWS SDK for Swift to perform a variety + // of operations using Amazon Relational Database Service (RDS). + // + + import ArgumentParser + import Foundation + import AWSRDS + + struct ExampleCommand: ParsableCommand { + @Option(help: "The AWS Region to run AWS API calls in.") + var awsRegion = "us-east-1" + @Option(help: "The username to use for the database administrator.") + var dbUsername = "admin" + @Option(help: "The password to use for the database administrator.") + var dbPassword: String + + static var configuration = CommandConfiguration( + commandName: "rds-scenario", + abstract: """ + Performs various operations to demonstrate the use of Amazon RDS Instances + using the AWS SDK for Swift. + """, + discussion: """ + """ + ) + + /// Called by ``main()`` to run the bulk of the example. + func runAsync() async throws { + let example = try await Example(region: awsRegion, username: dbUsername, password: dbPassword) + + await example.run() + } + } + + class Example { + let rdsClient: RDSClient + + // Storage for AWS RDS properties + + let dbUsername: String + let dbPassword: String + var dbInstanceIdentifier: String + var dbSnapshotIdentifier: String + var dbParameterGroupName: String + var dbParameterGroup: RDSClientTypes.DBParameterGroup? + var selectedEngineVersion: String? + + init(region: String, username: String, password: String) async throws{ + let rdsConfig = try await RDSClient.RDSClientConfiguration(region: region) + rdsClient = RDSClient(config: rdsConfig) + + dbUsername = username + dbPassword = password + dbParameterGroupName = "" + dbInstanceIdentifier = "" + dbSnapshotIdentifier = "" + } + + /// The example's main body. + func run() async { + var parameterGroupFamilies: Set<String> = [] + + //===================================================================== + // 1. Get available database engine families for MySQL. + //===================================================================== + + let engineVersions = await getDBEngineVersions(engineName: "mysql") + + for version in engineVersions { + if version.dbParameterGroupFamily != nil { + parameterGroupFamilies.insert(version.dbParameterGroupFamily!) + } + } + + if engineVersions.count > 0 { + selectedEngineVersion = engineVersions.last!.engineVersion + } else { + print("*** Unable to find a valid database engine version. Canceling operations.") + await cleanUp() + return + } + + print("Found \(parameterGroupFamilies.count) parameter group families:") + for family in parameterGroupFamilies { + print(" \(family)") + } + + //===================================================================== + // 2. Select an engine family and create a custom DB parameter group. + // We select a family by sorting the set of family names, then + // choosing the last one. + //===================================================================== + + let sortedFamilies = parameterGroupFamilies.sorted() + + guard let selectedFamily = sortedFamilies.last else { + print("*** Unable to find a database engine family. Canceling operations.") + await cleanUp() + return + } + + print("Selected database engine family \(selectedFamily)") + + dbParameterGroupName = tempName(prefix: "rds-example") + print("Creating a database parameter group named \(dbParameterGroupName) using \(selectedFamily)") + dbParameterGroup = await createDBParameterGroup(groupName: dbParameterGroupName, + familyName: selectedFamily) + + //===================================================================== + // 3. Get the parameter group's details. + //===================================================================== + + print("Getting the database parameter group list...") + let dbParameterGroupList = await describeDBParameterGroups(groupName: dbParameterGroupName) + guard let dbParameterGroupList else { + await cleanUp() + return + } + + print("Found \(dbParameterGroupList.count) parameter groups...") + for group in dbParameterGroupList { + print(" \(group.dbParameterGroupName ?? "<unknown>")") + } + print() + + //===================================================================== + // 4. Get a list of the parameter group's parameters. This list is + // likely to be long, so use pagination. Find the + // auto_increment_offset and auto_increment_increment parameters. + //===================================================================== + + let parameters = await describeDBParameters(groupName: dbParameterGroupName) + + //===================================================================== + // 5. Parse and display each parameter's name, description, and + // allowed values. + //===================================================================== +