Name:
interface
Value:
Extend your Amplify Gen 2 app with AWS Blocks — self-contained backend capabilities you compose into your existing backend.
Gen1 DocsLegacy

Page updated Sep 24, 2024

NewDeploy web apps with Git or your AI coding agent using the latest AWS Amplify. Add managed databases and authentication as you grow. Explore the documentation.
NoticeAmplify Gen 1 has entered maintenance mode and will reach end of life on May 1, 2027.

Use AWS SDK

These docs cover Amplify Gen 2. For new web apps, we recommend the latest AWS Amplify, with a simplified CLI and native integrations for databases, storage, and AI models. Get started with the latest AWS Amplify.

For advanced use cases where Amplify does not provide the functionality, you can retrieve an escape hatch to access the underlying Amazon Cognito client.

The escape hatch provides access to the underlying AWSCognitoIdentityProvider instance. Import the necessary types:

import AWSCognitoAuthPlugin
import AWSCognitoIdentityProvider

Then retrieve the escape hatch with this code:

func getEscapeHatch() {
let client: CognitoIdentityProviderClient
// Get the instance of AWSCognitoAuthPlugin
let plugin = try? Amplify.Auth.getPlugin(for: "awsCognitoAuthPlugin") as? AWSCognitoAuthPlugin
// Get the instance of CognitoIdentityProviderClient
if case .userPoolAndIdentityPool(let userPoolClient, _) = plugin?.getEscapeHatch() {
client = userPoolClient
} else if case .userPool(let userPoolClient) = plugin?.getEscapeHatch() {
client = userPoolClient
} else {
fatalError("No user pool configuration found")
}
print("Fetched escape hatch - \(String(describing: client))")
}