Overriding resources
When defining resources you can access some underlying AWS CDK construct props to modify resource configurations.
Customize Cognito UserPool email verification settings
1import { defineAuth } from "@aws-amplify/backend";2
3export const auth = defineAuth({4 loginWith: {5 email: {6 verificationEmailStyle: "CODE",7 verificationEmailBody: (code: string) =>8 `Welcome! Your verification code is ${code}.`,9 verificationEmailSubject: "Welcome! Here is your verification code",10 },11 },12});
Alternatively you can mutate the synthesized CDK constructs directly after setting them on your backend
:
Override Cognito UserPool password policies
1import { Backend } from '@aws-amplify/backend';2import { auth } from './auth/resource';3
4const backend = new Backend({5 auth,6});7
8// override userpool password policies9backend.resources.auth.resources.cfnResources.cfnUserPool.addPropertyOverride(10 "Policies",11 {12 PasswordPolicy: {13 MinimumLength: 10,14 RequireLowercase: true,15 RequireNumbers: true,16 RequireSymbols: true,17 RequireUppercase: true,18 TemporaryPasswordValidityDays: 20,19 },20 }21);
Below are additional example scenarios where you may want to override resources.
Add tags to resources
Amplify Data's underlying GraphQL API
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
10backend.resources.data.resources.cfnResources.cfnGraphqlApi.addPropertyOverride(11 "Tags",12 [13 {14 Key: "graphqlapi-tag-1",15 Value: "graphql-tag-value-1",16 },17 {18 Key: "graphqlapi-tag-2",19 Value: "graphql-tag-value-2",20 },21 ]22);