
AWS SDK for Swift
OfficialFreeStreamline your Swift development with AWS services.
Free · Opens the source repo
What AWS SDK for Swift does
The AWS SDK for Swift skill provides developers with essential patterns and best practices for integrating AWS services into their Swift applications. It focuses on asynchronous programming, which is crucial for handling AWS service calls efficiently. By using the provided code snippets and guidelines, developers can quickly set up service clients and manage AWS resources with ease.
One of the key aspects of this skill is the emphasis on using struct-based configuration types instead of the deprecated class-based ones. This change not only aligns with Swift's modern programming paradigms but also ensures that developers are using the most up-to-date practices. The skill provides clear examples of how to create clients for various AWS services like S3 and DynamoDB, detailing the required configuration parameters and their order, which is critical for successful client initialization.
Additionally, the skill covers advanced topics such as credential resolvers, pagination, and presigned URLs, which are essential for managing AWS resources effectively. For instance, it explains how to implement static credentials and role assumption, along with how to handle pagination when retrieving large datasets. This comprehensive approach makes it suitable for both novice and experienced Swift developers looking to leverage AWS services in their applications.
Overall, this skill serves as a valuable resource for anyone developing Swift applications that require AWS integration, ensuring that they follow best practices and utilize the SDK effectively.
When to use it
Use this skill when developing Swift applications that require interaction with AWS services, ensuring you follow the latest SDK patterns.
When not to use it
This skill is not suitable for non-Swift projects or for developers who are not using AWS services in their applications.
What you can build with it
Integrating S3 in a Swift App
Use this skill to set up an S3 client for uploading and retrieving files in your Swift application.
Managing DynamoDB Data
Follow the provided patterns to create a DynamoDB client and perform CRUD operations on your data.
Implementing Credential Management
Learn how to securely manage AWS credentials in your Swift applications using the recommended credential resolvers.
How to install AWS SDK for Swift
View source1. Install with the skills CLI
npx skills add aws/agent-toolkit-for-aws/aws-sdk-swift-usage --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by awsAWS SDK for Swift
Async Code Structure
All SDK operations are async. Use @main entry point:
@main
struct Main {
static func main() async throws {
let client = try await S3Client()
// ... async operations
}
}
CRITICAL: Use Struct Config Types
NEVER use S3ClientConfiguration or DynamoDBClientConfiguration - these are DEPRECATED classes.
ALWAYS use the struct-based config types:
S3Client.S3ClientConfig(not S3ClientConfiguration)DynamoDBClient.DynamoDBClientConfig(not DynamoDBClientConfiguration)STSClient.STSClientConfig(not STSClientConfiguration)
Config parameters MUST be in declaration order. Region is ALWAYS required when creating a config. Check the service client source for exact order.
// CORRECT - struct config
let config = try await S3Client.S3ClientConfig(region: "us-west-2")
let client = S3Client(config: config)
// WRONG - deprecated class
// let config = try await S3Client.S3ClientConfiguration(region: "us-west-2")
Client Creation
All service clients follow the same pattern: <Service>Client with <Service>Client.<Service>ClientConfig.
Model types (structs/enums used in requests/responses) are namespaced under <Service>ClientTypes:
S3ClientTypes.Bucket,S3ClientTypes.ObjectDynamoDBClientTypes.AttributeValueCloudWatchClientTypes.MetricDatum,CloudWatchClientTypes.Dimension
import AWSS3
import AWSDynamoDB
// Simple - auto-detects region
let s3 = try await S3Client()
let dynamo = try await DynamoDBClient()
// With region
let s3 = try S3Client(region: "us-west-2")
// With config - parameters must be in declaration order
let config = try await S3Client.S3ClientConfig(
useFIPS: true,
awsRetryMode: .adaptive,
maxAttempts: 5,
region: "us-west-2"
)
let client = S3Client(config: config)
// With custom endpoint and credentials
let config = try await S3Client.S3ClientConfig(
awsCredentialIdentityResolver: resolver,
region: "us-west-2",
endpoint: "https://s3.custom-endpoint.com"
)
Common config parameters (MUST follow declaration order):
-
awsCredentialIdentityResolver- Custom credentials -
useFIPS- Enable FIPS endpoints -
useDualStack- Enable dual-stack endpoints -
awsRetryMode- Retry strategy (.adaptive, .standard, .legacy) -
maxAttempts- Max retry attempts -
region- AWS region -
httpClientEngine- Custom HTTP client (requires HttpClientConfiguration parameter):import ClientRuntime let httpConfig = HttpClientConfiguration() let httpClient = URLSessionHTTPClient(httpClientConfiguration: httpConfig) let config = try await S3Client.S3ClientConfig( region: "us-east-1", httpClientEngine: httpClient ) -
endpoint- Custom endpoint URL
For service-specific config options or exact parameter order, check Sources/Services/AWS<Service>/Sources/AWS<Service>/<Service>Client.swift in the SDK.
Credential Resolvers
import AWSSDKIdentity
import SmithyIdentity
// Static credentials - pass credential object directly
let creds = AWSCredentialIdentity(accessKey: "AKIA...", secret: "...")
let resolver = StaticAWSCredentialIdentityResolver(creds)
// Assume role - REQUIRES underlying resolver
let underlying = try DefaultAWSCredentialIdentityResolverChain()
let resolver = try STSAssumeRoleAWSCredentialIdentityResolver(
awsCredentialIdentityResolver: underlying,
roleArn: "arn:aws:iam::123456789012:role/MyRole",
sessionName: "session-name"
)
// Use in config
let config = try await S3Client.S3ClientConfig(
awsCredentialIdentityResolver: resolver,
region: "us-west-2"
)
Waiters
Import SmithyWaitersAPI. WaiterOptions requires maxWaitTime parameter:
import AWSS3
import SmithyWaitersAPI
let client = try await S3Client()
_ = try await client.waitUntilBucketExists(
options: WaiterOptions(maxWaitTime: 120.0),
input: HeadBucketInput(bucket: "my-bucket")
)
Pagination
let input = ListObjectsV2Input(bucket: "my-bucket")
for try await page in client.listObjectsV2Paginated(input: input) {
for object in page.contents ?? [] {
print(object.key ?? "")
}
}
Presigned URLs
let url = try await client.presignedURLForGetObject(
input: GetObjectInput(bucket: "my-bucket", key: "file.pdf"),
expiration: 3600
)
Common Operations
// Put object
_ = try await client.putObject(input: PutObjectInput(
body: .data(data),
bucket: "bucket",
key: "key"
))
// Get object
let output = try await client.getObject(input: GetObjectInput(bucket: "bucket", key: "key"))
let data = try await output.body?.readData()
// List buckets
let response = try await client.listBuckets(input: ListBucketsInput())
for bucket in response.buckets ?? [] {
print(bucket.name ?? "")
}
Frequently asked questions about AWS SDK for Swift
Similar skills
WinMD API Search
Easily find and explore Windows desktop APIs.
WebMCPify
Transform any web app into an agent-ready platform.
Phoenix Tracing
Instrument LLM applications with OpenInference tracing.
Foundry Hosted Agent CopilotKit
Guidance for developing agentic web apps on Azure.
Power Automate Foundation
Connect AI agents to Power Automate seamlessly.
Power Automate Flow Builder
Efficiently build and deploy Power Automate flows programmatically.
