Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Page updated Feb 21, 2024

Maintenance ModeYou are viewing Amplify Gen 1 documentation. Amplify Gen 1 has entered maintenance mode and will reach end of life on May 1, 2027. New project should use Amplify Gen 2. For existing Gen 1 projects, a migration guide and tooling are available to help you upgrade. Switch to the latest Gen 2 docs →

Use AWS SDK

For advanced use cases where Amplify does not provide the functionality you're looking for, you can retrieve the escape hatch to access the underlying SDK.

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))")
}