Skip to content

Swift: RDS scenario example #7545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Aug 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions .doc_gen/metadata/rds_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ rds_CreateDBInstance:
- description:
snippet_tags:
- php.example_code.rds.createDBInstance.complete
Swift:
versions:
- sdk_version: 1
github: swift/example_code/rds
excerpts:
- description:
snippet_tags:
- swift.rds.import
- swift.rds.CreateDBInstance
services:
rds: {CreateDBInstance}
rds_DeleteDBInstance:
Expand Down Expand Up @@ -194,6 +203,15 @@ rds_DeleteDBInstance:
- description:
snippet_tags:
- php.example_code.rds.deleteDBInstance.complete
Swift:
versions:
- sdk_version: 1
github: swift/example_code/rds
excerpts:
- description:
snippet_tags:
- swift.rds.import
- swift.rds.DeleteDBInstance
services:
rds: {DeleteDBInstance}
rds_DescribeAccountAttributes:
Expand Down Expand Up @@ -292,6 +310,15 @@ rds_DescribeDBInstances:
- description:
snippet_tags:
- php.example_code.rds.describeDBInstances.complete
Swift:
versions:
- sdk_version: 1
github: swift/example_code/rds
excerpts:
- description:
snippet_tags:
- swift.rds.import
- swift.rds.DescribeDBInstances
services:
rds: {DescribeDBInstances}
rds_ModifyDBInstance:
Expand Down Expand Up @@ -389,6 +416,15 @@ rds_DescribeDBParameterGroups:
- cpp.example_code.rds.client
- cpp.example_code.rds.DescribeDBParameterGroups1
- cpp.example_code.rds.DescribeDBParameterGroups2
Swift:
versions:
- sdk_version: 1
github: swift/example_code/rds
excerpts:
- description:
snippet_tags:
- swift.rds.import
- swift.rds.DescribeDBParameterGroups
services:
rds: {DescribeDBParameterGroups}
rds_CreateDBParameterGroup:
Expand Down Expand Up @@ -441,6 +477,15 @@ rds_CreateDBParameterGroup:
- cpp.example_code.rds.client_configuration
- cpp.example_code.rds.client
- cpp.example_code.rds.CreateDBParameterGroup
Swift:
versions:
- sdk_version: 1
github: swift/example_code/rds
excerpts:
- description:
snippet_tags:
- swift.rds.import
- swift.rds.CreateDBParameterGroup
services:
rds: {CreateDBParameterGroup}
rds_DeleteDBParameterGroup:
Expand Down Expand Up @@ -493,6 +538,15 @@ rds_DeleteDBParameterGroup:
- cpp.example_code.rds.client_configuration
- cpp.example_code.rds.client
- cpp.example_code.rds.DeleteDBParameterGroup
Swift:
versions:
- sdk_version: 1
github: swift/example_code/rds
excerpts:
- description:
snippet_tags:
- swift.rds.import
- swift.rds.DeleteDBParameterGroup
services:
rds: {DeleteDBParameterGroup}
rds_DescribeDBParameters:
Expand Down Expand Up @@ -554,6 +608,15 @@ rds_DescribeDBParameters:
- cpp.example_code.rds.client_configuration
- cpp.example_code.rds.client
- cpp.example_code.rds.DescribeDBParameters
Swift:
versions:
- sdk_version: 1
github: swift/example_code/rds
excerpts:
- description:
snippet_tags:
- swift.rds.import
- swift.rds.DescribeDBParameters
services:
rds: {DescribeDBParameters}
rds_ModifyDBParameterGroup:
Expand Down Expand Up @@ -606,6 +669,15 @@ rds_ModifyDBParameterGroup:
- cpp.example_code.rds.client_configuration
- cpp.example_code.rds.client
- cpp.example_code.rds.ModifyDBParameterGroup
Swift:
versions:
- sdk_version: 1
github: swift/example_code/rds
excerpts:
- description:
snippet_tags:
- swift.rds.import
- swift.rds.ModifyDBParameterGroup
services:
rds: {ModifyDBParameterGroup}
rds_CreateDBSnapshot:
Expand Down Expand Up @@ -675,6 +747,15 @@ rds_CreateDBSnapshot:
- description:
snippet_tags:
- php.example_code.rds.createDBSnapshot.complete
Swift:
versions:
- sdk_version: 1
github: swift/example_code/rds
excerpts:
- description:
snippet_tags:
- swift.rds.import
- swift.rds.CreateDBSnapshot
services:
rds: {CreateDBSnapshot}
rds_DescribeDBSnapshots:
Expand Down Expand Up @@ -727,6 +808,15 @@ rds_DescribeDBSnapshots:
- cpp.example_code.rds.client_configuration
- cpp.example_code.rds.client
- cpp.example_code.rds.DescribeDBSnapshots
Swift:
versions:
- sdk_version: 1
github: swift/example_code/rds
excerpts:
- description:
snippet_tags:
- swift.rds.import
- swift.rds.DescribeDBSnapshots
services:
rds: {DescribeDBSnapshots}
rds_DescribeDBEngineVersions:
Expand Down Expand Up @@ -779,6 +869,15 @@ rds_DescribeDBEngineVersions:
- cpp.example_code.rds.client_configuration
- cpp.example_code.rds.client
- cpp.example_code.rds.DescribeDBEngineVersions
Swift:
versions:
- sdk_version: 1
github: swift/example_code/rds
excerpts:
- description:
snippet_tags:
- swift.rds.import
- swift.rds.DescribeDBEngineVersions
services:
rds: {DescribeDBEngineVersions}
rds_DescribeOrderableDBInstanceOptions:
Expand Down Expand Up @@ -822,6 +921,15 @@ rds_DescribeOrderableDBInstanceOptions:
- cpp.example_code.rds.client_configuration
- cpp.example_code.rds.client
- cpp.example_code.rds.DescribeOrderableDBInstanceOptions
Swift:
versions:
- sdk_version: 1
github: swift/example_code/rds
excerpts:
- description:
snippet_tags:
- swift.rds.import
- swift.rds.DescribeOrderableDBInstanceOptions
services:
rds: {DescribeOrderableDBInstanceOptions}
rds_GenerateRDSAuthToken:
Expand Down Expand Up @@ -916,6 +1024,17 @@ rds_Scenario_GetStartedInstances:
snippet_tags:
- cpp.example_code.rds.client_configuration
- cpp.example_code.rds.get_started_instances
Swift:
versions:
- sdk_version: 1
github: swift/example_code/rds
excerpts:
- description: The <code>Package.swift</code> file.
snippet_tags:
- swift.rds.scenario.package
- description: The Swift code file, <code>entry.swift</code>.
snippet_tags:
- swift.rds.scenario
services:
rds: {CreateDBInstance, CreateDBParameterGroup, CreateDBSnapshot, DeleteDBInstance, DeleteDBParameterGroup, DescribeDBInstances,
DescribeDBEngineVersions, DescribeDBParameterGroups, DescribeDBParameters, DescribeDBSnapshots, DescribeOrderableDBInstanceOptions,
Expand Down
123 changes: 123 additions & 0 deletions swift/example_code/rds/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Amazon RDS code examples for the SDK for Swift

## Overview

Shows how to use the AWS SDK for Swift to work with Amazon Relational Database Service (Amazon RDS).

<!--custom.overview.start-->
<!--custom.overview.end-->

_Amazon RDS is a web service that makes it easier to set up, operate, and scale a relational database in the cloud._

## ⚠ Important

* Running this code might result in charges to your AWS account. For more details, see [AWS Pricing](https://aws.amazon.com/pricing/) and [Free Tier](https://aws.amazon.com/free/).
* Running the tests might result in charges to your AWS account.
* We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege).
* This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services).

<!--custom.important.start-->
<!--custom.important.end-->

## Code examples

### Prerequisites

For prerequisites, see the [README](../../README.md#Prerequisites) in the `swift` folder.


<!--custom.prerequisites.start-->
<!--custom.prerequisites.end-->

### Basics

Code examples that show you how to perform the essential operations within a service.

- [Learn the basics](scenario/Package.swift)


### Single actions

Code excerpts that show you how to call individual service functions.

- [CreateDBInstance](scenario/Sources/entry.swift#L529)
- [CreateDBParameterGroup](scenario/Sources/entry.swift#L326)
- [CreateDBSnapshot](scenario/Sources/entry.swift#L627)
- [DeleteDBInstance](scenario/Sources/entry.swift#L705)
- [DeleteDBParameterGroup](scenario/Sources/entry.swift#L770)
- [DescribeDBEngineVersions](scenario/Sources/entry.swift#L303)
- [DescribeDBInstances](scenario/Sources/entry.swift#L581)
- [DescribeDBParameterGroups](scenario/Sources/entry.swift#L350)
- [DescribeDBParameters](scenario/Sources/entry.swift#L374)
- [DescribeDBSnapshots](scenario/Sources/entry.swift#L656)
- [DescribeOrderableDBInstanceOptions](scenario/Sources/entry.swift#L478)
- [ModifyDBParameterGroup](scenario/Sources/entry.swift#L413)


<!--custom.examples.start-->
<!--custom.examples.end-->

## Run the examples

### Instructions

To build any of these examples from a terminal window, navigate into its
directory, then use the following command:

```
$ swift build
```

To build one of these examples in Xcode, navigate to the example's directory
(such as the `ListUsers` directory, to build that example). Then type `xed.`
to open the example directory in Xcode. You can then use standard Xcode build
and run commands.

<!--custom.instructions.start-->
<!--custom.instructions.end-->


#### Learn the basics

This example shows you how to do the following:

- Create a custom DB parameter group and set parameter values.
- Create a DB instance that's configured to use the parameter group. The DB instance also contains a database.
- Take a snapshot of the instance.
- Delete the instance and parameter group.

<!--custom.basic_prereqs.rds_Scenario_GetStartedInstances.start-->
<!--custom.basic_prereqs.rds_Scenario_GetStartedInstances.end-->


<!--custom.basics.rds_Scenario_GetStartedInstances.start-->
<!--custom.basics.rds_Scenario_GetStartedInstances.end-->


### Tests

⚠ Running tests might result in charges to your AWS account.


To find instructions for running these tests, see the [README](../../README.md#Tests)
in the `swift` folder.



<!--custom.tests.start-->
<!--custom.tests.end-->

## Additional resources

- [Amazon RDS User Guide](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Welcome.html)
- [Amazon RDS API Reference](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/Welcome.html)
- [SDK for Swift Amazon RDS reference](https://sdk.amazonaws.com/swift/api/awsrds/latest/documentation/awsrds)

<!--custom.resources.start-->
<!--custom.resources.end-->

---

Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
47 changes: 47 additions & 0 deletions swift/example_code/rds/scenario/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// swift-tools-version: 5.9
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//
// (swift-tools-version has two lines here because it needs to be the first
// line in the file, but it should also appear in the snippet below)
//
// snippet-start:[swift.rds.scenario.package]
// 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")

]
)
// snippet-end:[swift.rds.scenario.package]
Loading
Loading