I want to remove the Cognito user pool from the available identity providers in the Hosted UI. Typically, this can be done manually through the AWS Cognito Console by following these steps:
- Navigate to User pools.
- Select the User pool (e.g., User pool xxx).
- Go to App integration.
- Choose the relevant app client (e.g., userPoolAppClientXXX) in the App client list.
- Under Hosted UI, click Edit and remove Cognito user pool from the list of identity providers.
However, my goal is to automate this process via code, avoiding the need for manual updates for every environment.
Currently, I added a propertyOverride to my backend.ts file. This approach works when the authentication resource was already created in a previous "push". However, it fails when creating a new environment (e.g., a sandbox) because the "Google" identity provider has not been created yet.
Here is my current code:
export const backend = defineBackend({
auth,
data,
});
const { cfnUserPool, cfnUserPoolClient } = backend.auth.resources.cfnResources;
cfnUserPoolClient.addPropertyOverride("SupportedIdentityProviders", ["Google"]);
The error I encounter is:
The provider Google does not exist for User Pool eu-central-1_kRc6Z7qhj.
Question:
How can I ensure that the property override is executed only after Google has been registered as an identity provider in a push? Alternatively, is there another method to remove Cognito user pool from the app client programmatically?