aws-cloudformation / aws-cloudformation/cloudformation-coverage-roadmap
[AWS:Cognito] - [BUG] - Cannot create cfn user pool with only email MFA enabled
- Dominant language
- No language data
- Stars
- 1.1k
- Forks
- 62
- PR merge metrics
- No merged PRs in 30d
Description
### Name of the resource
AWS::Cognito::UserPool
### Resource Name
AWS:COGNITO:USERPOOL
### Issue Description
User is trying to create a Cognito user pool using the L1 construct and ONLY email MFA enabled leads to an error in CloudFormation.
This DOES work if I create the same user pool without any MFA enabled and then go to the AWS console and update it manually to have email only MFA.
### Expected Behavior
CloudFormation is able to create the requested resource without issues.
### Observed Behavior
Error received -
```
Resource handler returned message: "SMS configuration and Auto verification for phone_number are required when MFA is required/optional (Service: CognitoIdentityProvider, Status Code: 400, Request ID: ..., HandlerErrorCode: InvalidRequest)
```
### Test Cases
Here is an example of a stack that yields the error in CloudFormation
```ts
import * as cognito from 'aws-cdk-lib/aws-cognito';
import { App, Stack, StackProps } from 'aws-cdk-lib/core';
export class AuthStack extends Stack {
constructor(scope: App, id: string, props: StackProps) {
super(scope, id, props);
const userPool = new cognito.CfnUserPool(this, 'UserPool', {
userPoolName: 'UserPool123',
adminCreateUserConfig: {
allowAdminCreateUserOnly: true,
unusedAccountValidityDays: 1,
},
usernameAttributes: ['email'],
usernameConfiguration: {
caseSensitive: false,
},
enabledMfas: ['EMAIL_OTP'],
mfaConfiguration: 'OPTIONAL',
});
}
}
```
user also tried giving `EmailConfiguration` in the [docs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cognito-userpool.html#aws-resource-cognito-userpool-properties) but it still yields the same error
### Other Details
Origiinal issue reported in CDK -https://github.com/aws/aws-cdk/issues/32615
Previous issue ( not similar but linked) - https://github.com/aws/aws-cdk/issues/11478
Contributor guide
Research direction
Start with the TypeScript CfnUserPool example in the issue and reproduce the CloudFormation error using enabledMfas: ['EMAIL_OTP'] and mfaConfiguration: 'OPTIONAL'. Compare the requested properties with the linked CloudFormation Cognito UserPool documentation and CDK issue 32615. Done means the same stack creates successfully with email-only MFA without requiring SMS configuration or phone auto-verification.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100