Skip to content

aws-cognito: Cannot customise "Verify email" string in emailBody of UserPool userVerification #23828

@fdansey-ostmodern

Description

@fdansey-ostmodern

Describe the bug

When I change the text in the "{##Verify Email##}" placeholder, e.g. to "{##verify your email##}", cdk synth and cdk deploy commands yield the error,

Error: Verification email body must contain the template string '{##Verify Email##}'

This is incorrect as that documentation states that this string may be customised.
https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pool-settings-email-verification-message-customization.html

Help text in the AWS Cognito console reads:

You can customize this message with HTML. "Verify email" is the text that will be displayed over the clickable link in the message. You can customize the "Verify email" string, but the variable - some text enclosed by "{##" and "##}" - must be kept in the message.

Expected Behavior

I am able to change the emailBody property of a UserPool to include the placeholder of format, "{##Verify Your Email##}" with any custom string allowed by AWS Cognito.

Current Behavior

cdk synth and cdk deploy commands yield the error,

Error: Verification email body must contain the template string '{##Verify Email##}'
at UserPool.verificationMessageConfiguration (/node_modules/aws-cdk-lib/aws-cognito/lib/user-pool.js:1:10661)
at new UserPool (/node_modules/aws-cdk-lib/aws-cognito/lib/user-pool.js:1:4946)
at new BlarnStack (/blarn-stack/blarn-stack.ts:75:22)
at Object. (/stack-blarn.ts:12:1)
at Module._compile (node:internal/modules/cjs/loader:1218:14)
at Module.m._compile (/node_modules/ts-node/src/index.ts:1455:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
at Object.require.extensions. [as .ts] (/node_modules/ts-node/src/index.ts:1458:12)
at Module.load (node:internal/modules/cjs/loader:1081:32)
at Function.Module._load (node:internal/modules/cjs/loader:922:12)

Reproduction Steps

Create a stack containing a cognito.UserPool resource with property,

userVerification: {
  emailSubject: "Please verify your email",
  emailBody: `<p>Hello Hottie Pingi!</p>
<p>Please {##verify your email address##}</p>`,
  emailStyle: cognito.VerificationEmailStyle.LINK,
}

Run cdk synth on the stack.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.61.0 (build 34f4926)

Framework Version

No response

Node.js Version

v18.13.0

OS

Ubuntu 22.04.1 LTS

Language

Typescript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-cognitoRelated to Amazon CognitobugThis issue is a bug.effort/smallSmall work item – less than a day of effortp2

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions