Connect to existing AWS resources
Amplify client libraries can be used independently without the Amplify backend workflow. If you've provisioned AWS resources with CDK, Terraform, CloudFormation, or the AWS Console, you can connect Amplify libraries directly to those resources.
This means you can adopt Amplify's client libraries for authentication, data, storage, and more — while keeping full control over your infrastructure.
When to use this approach
- You already have AWS resources provisioned with CDK, Terraform, or CloudFormation
- You want to use Amplify client libraries without adopting the Amplify backend (
ampx) workflow - You need to connect to shared infrastructure managed by a platform team
- You want programmatic control over configuration for testing or environment switching
How it works
There are two ways to configure Amplify client libraries with your own resources:
Option 1: Manual amplify_outputs.json
Create an amplify_outputs.json file in your Xcode project. See the full specification for all supported fields.
{ "version": "1", "auth": { "aws_region": "us-east-1", "user_pool_id": "us-east-1_abc123", "user_pool_client_id": "abcdef123456", "identity_pool_id": "us-east-1:11111111-2222-3333-4444-555555555555" }}Then configure Amplify as usual:
try Amplify.add(plugin: AWSCognitoAuthPlugin())try Amplify.configure(with: .amplifyOutputs)Option 2: Programmatic configuration with AmplifyOutputsData
Build the configuration in code without any JSON files:
import Amplifyimport AWSCognitoAuthPlugin
let config = AmplifyOutputsData( auth: .init( awsRegion: "us-east-1", userPoolId: "us-east-1_abc123", userPoolClientId: "abcdef123456" ))
try Amplify.add(plugin: AWSCognitoAuthPlugin())try Amplify.configure(config)This approach is ideal for:
- Unit testing — Configure Amplify without bundling JSON files
- Environment switching — Build different configurations for dev/staging/prod
- Dynamic configuration — Fetch configuration from a remote source at runtime
Configure Auth (Amazon Cognito)
Connect to an existing Cognito User Pool and Identity Pool.
let config = AmplifyOutputsData( auth: .init( awsRegion: "us-east-1", userPoolId: "us-east-1_abc123", userPoolClientId: "abcdef123456", identityPoolId: "us-east-1:11111111-2222-3333-4444-555555555555", passwordPolicy: .init( minLength: 8, requireNumbers: true, requireLowercase: true, requireUppercase: true, requireSymbols: false ), oauth: .init( identityProviders: ["GOOGLE", "SIGN_IN_WITH_APPLE"], domain: "myapp.auth.us-east-1.amazoncognito.com", scopes: ["openid", "email", "profile"], redirectSignInUri: ["myapp://callback"], redirectSignOutUri: ["myapp://signout"], responseType: "code" ), standardRequiredAttributes: [.email], usernameAttributes: [.email], userVerificationTypes: [.email], unauthenticatedIdentitiesEnabled: true, mfaConfiguration: "OPTIONAL", mfaMethods: ["SMS", "TOTP"] ))
try Amplify.add(plugin: AWSCognitoAuthPlugin())try Amplify.configure(config)Auth required fields
| Field | Required | Description |
|---|---|---|
awsRegion | Yes | AWS region (e.g. us-east-1) |
userPoolId | Yes | Cognito User Pool ID |
userPoolClientId | Yes | Cognito app client ID |
identityPoolId | No | Cognito Identity Pool ID (needed for guest access and IAM-based auth) |
passwordPolicy | No | Password requirements (min length, character types) |
oauth | No | OAuth/Hosted UI configuration (social sign-in) |
mfaConfiguration | No | MFA mode: NONE, OPTIONAL, or REQUIRED |
mfaMethods | No | MFA types: SMS, TOTP |
Configure Data (AWS AppSync)
Connect to an existing AppSync GraphQL API.
let config = AmplifyOutputsData( data: .init( awsRegion: "us-east-1", url: "https://abc123.appsync-api.us-east-1.amazonaws.com/graphql", apiKey: "da2-abcdefghijklmno", defaultAuthorizationType: .apiKey, authorizationTypes: [.apiKey, .amazonCognitoUserPools] ))
try Amplify.add(plugin: AWSAPIPlugin())try Amplify.configure(config)Data required fields
| Field | Required | Description |
|---|---|---|
awsRegion | Yes | AWS region |
url | Yes | AppSync GraphQL endpoint URL |
defaultAuthorizationType | Yes | Default auth mode: API_KEY, AMAZON_COGNITO_USER_POOLS, AWS_IAM, or OPENID_CONNECT |
authorizationTypes | Yes | All supported auth modes |
apiKey | No | Required if using API_KEY auth |
Configure Storage (Amazon S3)
Connect to an existing S3 bucket.
let config = AmplifyOutputsData( auth: .init( awsRegion: "us-east-1", userPoolId: "us-east-1_abc123", userPoolClientId: "abcdef123456", identityPoolId: "us-east-1:11111111-2222-3333-4444-555555555555" ), storage: .init( awsRegion: "us-east-1", bucketName: "my-app-bucket" ))
try Amplify.add(plugin: AWSCognitoAuthPlugin())try Amplify.add(plugin: AWSS3StoragePlugin())try Amplify.configure(config)Multiple buckets
let config = AmplifyOutputsData( storage: .init( awsRegion: "us-east-1", bucketName: "primary-bucket", buckets: [ .init(name: "media", bucketName: "my-media-bucket", awsRegion: "us-east-1"), .init(name: "logs", bucketName: "my-logs-bucket", awsRegion: "us-west-2") ] ))Storage required fields
| Field | Required | Description |
|---|---|---|
awsRegion | Yes | AWS region |
bucketName | Yes | Default S3 bucket name |
buckets | No | Additional named buckets for multi-bucket setups |
Configure Analytics (Amazon Pinpoint)
Connect to an existing Pinpoint application.
let config = AmplifyOutputsData( analytics: .init( amazonPinpoint: .init( awsRegion: "us-east-1", appId: "abc123def456" ) ))
try Amplify.add(plugin: AWSPinpointAnalyticsPlugin())try Amplify.configure(config)Configure Geo (Amazon Location Service)
Connect to existing Location Service resources.
let config = AmplifyOutputsData( geo: .init( awsRegion: "us-east-1", maps: .init( items: ["myMap": .init(style: "VectorEsriStreets")], default: "myMap" ), searchIndices: .init( items: ["myPlaceIndex"], default: "myPlaceIndex" ), geofenceCollections: .init( items: ["myGeofenceCollection"], default: "myGeofenceCollection" ) ))
try Amplify.add(plugin: AWSLocationGeoPlugin())try Amplify.configure(config)Configure Notifications (Push)
Connect to an existing Pinpoint application for push notifications.
let config = AmplifyOutputsData( notifications: .init( awsRegion: "us-east-1", amazonPinpointAppId: "abc123def456", channels: [.apns, .fcm, .inAppMessaging] ))
try Amplify.add(plugin: AWSPinpointPushNotificationsPlugin())try Amplify.configure(config)Multi-category configuration
You can configure multiple services together. This example sets up Auth, Data, and Storage in a single configuration.
let config = AmplifyOutputsData( auth: .init( awsRegion: "us-east-1", userPoolId: "us-east-1_abc123", userPoolClientId: "abcdef123456", identityPoolId: "us-east-1:11111111-2222-3333-4444-555555555555" ), data: .init( awsRegion: "us-east-1", url: "https://abc123.appsync-api.us-east-1.amazonaws.com/graphql", defaultAuthorizationType: .amazonCognitoUserPools, authorizationTypes: [.amazonCognitoUserPools, .awsIAM] ), storage: .init( awsRegion: "us-east-1", bucketName: "my-app-bucket" ))
try Amplify.add(plugin: AWSCognitoAuthPlugin())try Amplify.add(plugin: AWSAPIPlugin())try Amplify.add(plugin: AWSS3StoragePlugin())try Amplify.configure(config)Inspecting resolved configuration
You can inspect the configuration resolved from amplify_outputs.json:
let outputs = try AmplifyOutputs.amplifyOutputs.resolveConfiguration()
if let auth = outputs.auth { print("User Pool ID: \(auth.userPoolId)") print("Region: \(auth.awsRegion)") print("Identity Pool: \(auth.identityPoolId ?? "none")")}
if let storage = outputs.storage { print("Bucket: \(storage.bucketName)") print("Additional buckets: \(storage.buckets?.count ?? 0)")}
if let data = outputs.data { print("GraphQL endpoint: \(data.url)") print("Default auth: \(data.defaultAuthorizationType)")}Environment-specific configuration
Switch between dev, staging, and production without separate JSON files:
let region: Stringlet userPoolId: Stringlet clientId: String
switch environment {case .dev: region = "us-east-1" userPoolId = "us-east-1_dev123" clientId = "devClient123"case .staging: region = "us-west-2" userPoolId = "us-west-2_staging456" clientId = "stagingClient456"case .prod: region = "us-east-1" userPoolId = "us-east-1_prod789" clientId = "prodClient789"}
let config = AmplifyOutputsData( auth: .init( awsRegion: region, userPoolId: userPoolId, userPoolClientId: clientId ))
try Amplify.configure(config)amplify_outputs.json schema reference
For the full schema of all supported configuration fields, see the amplify_outputs.json reference.