AWS Security ChangesHomeSearch

AWS AmazonRDS documentation change

Service: AmazonRDS · 2025-08-16 · Documentation low

File: AmazonRDS/latest/UserGuide/example_rds_CreateDBInstance_section.md

Summary

Added Swift SDK code example for creating a database instance

Security assessment

This is a routine documentation update adding code samples. No security context or vulnerability mitigation is present in the changes.

Diff

diff --git a/AmazonRDS/latest/UserGuide/example_rds_CreateDBInstance_section.md b/AmazonRDS/latest/UserGuide/example_rds_CreateDBInstance_section.md
index cfb917575..5eec152a8 100644
--- a//AmazonRDS/latest/UserGuide/example_rds_CreateDBInstance_section.md
+++ b//AmazonRDS/latest/UserGuide/example_rds_CreateDBInstance_section.md
@@ -678,0 +679,70 @@ There's more on GitHub. Find the complete example and learn how to set up and ru
+
+
+
+
+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). 
+    
+    
+    import AWSRDS
+    
+        /// Create a new database instance.
+        /// 
+        /// - Parameters:
+        ///   - name: The name of the database to create.
+        ///   - instanceIdentifier: The identifier to give the new database
+        ///     instance.
+        ///   - parameterGroupName: The name of the parameter group to associate
+        ///     with the new database instance.
+        ///   - engine: The database engine to use.
+        ///   - engineVersion: The version of the database given by `engine` to
+        ///     use.
+        ///   - instanceClass: The memory and compute capacity of the database
+        ///     instance, such as `db.m5.large``.
+        ///   - username: The admin user's username to establish for the new
+        ///     instance.
+        ///   - password: The password to use for the specified user's access.
+        /// 
+        /// - Returns: A string indicating the ARN of the newly created database
+        ///   instance, or nil if the instance couldn't be created.
+        func createDBInstance(name: String, instanceIdentifier: String, parameterGroupName: String,
+                              engine: String, engineVersion: String, instanceClass: String,
+                              username: String, password: String) async -> String? {
+            do {
+                let output = try await rdsClient.createDBInstance(
+                    input: CreateDBInstanceInput(
+                        allocatedStorage: 100,
+                        dbInstanceClass: instanceClass,
+                        dbInstanceIdentifier: instanceIdentifier,
+                        dbName: name,
+                        dbParameterGroupName: parameterGroupName,
+                        engine: engine,
+                        engineVersion: engineVersion,
+                        masterUserPassword: password,
+                        masterUsername: username,
+                        storageType: "gp2"
+                    )
+                )
+    
+                guard let dbInstance = output.dbInstance else {
+                    print("*** Unable to get the database instance.")
+                    return nil
+                }
+    
+                return dbInstance.dbInstanceArn
+            } catch {
+                print("*** An error occurred while creating the database instance: \(error.localizedDescription)")
+                return nil
+            }
+        }
+    
+    
+
+  * For API details, see [CreateDBInstance](https://sdk.amazonaws.com/swift/api/awsrds/latest/documentation/awsrds/rdsclient/createdbinstance\(input:\)) in _AWS SDK for Swift API reference_.