Page updated Nov 20, 2023

Override Amplify-generated Cognito resources

The Amplify Auth features have default configurations for its features when you use the amplify/auth/resource.ts file.

// amplify/auth/resource.ts import { defineAuth } from '@aws-amplify/backend'; export const auth = defineAuth({ loginWith: { email: true } });
1// amplify/auth/resource.ts
2import { defineAuth } from '@aws-amplify/backend';
3
4export const auth = defineAuth({
5 loginWith: {
6 email: true
7 }
8});

You can customize your authentication resource to enable it to behave exactly as needed for your use cases by modifying it directly using AWS Cloud Development Kit (CDK)

import { defineBackend } from '@aws-amplify/backend'; import { auth } from './auth/resource.js'; import { data } from './data/resource.js'; const backend = defineBackend({ auth, data }); // extract L1 CfnUserPool resources const { cfnUserPool } = backend.resources.auth.resources.cfnResources; // use CDK's `addPropertyOverride` to modify properties directly cfnUserPool.addPropertyOverride('Policies.PasswordPolicy.MinimumLength', 32);
1import { defineBackend } from '@aws-amplify/backend';
2import { auth } from './auth/resource.js';
3import { data } from './data/resource.js';
4
5const backend = defineBackend({
6 auth,
7 data
8});
9
10// extract L1 CfnUserPool resources
11const { cfnUserPool } = backend.resources.auth.resources.cfnResources;
12// use CDK's `addPropertyOverride` to modify properties directly
13cfnUserPool.addPropertyOverride('Policies.PasswordPolicy.MinimumLength', 32);