Skip to content
v2.278.0

MfaSecondFactor ​

Struct Stable

The different ways in which a user pool can obtain their MFA token for sign in.

Example ​

ts
new cognito.UserPool(this, 'myuserpool', {
  // ...
  mfa: cognito.Mfa.REQUIRED,
  mfaSecondFactor: {
    sms: true,
    otp: true,
    email: false, // email-based MFA
  },
});
python
cognito.UserPool(self, "myuserpool",
    # ...
    mfa=cognito.Mfa.REQUIRED,
    mfa_second_factor=cognito.MfaSecondFactor(
        sms=True,
        otp=True,
        email=False
    )
)
java
UserPool.Builder.create(this, "myuserpool")
        // ...
        .mfa(Mfa.REQUIRED)
        .mfaSecondFactor(MfaSecondFactor.builder()
                .sms(true)
                .otp(true)
                .email(false)
                .build())
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
new UserPool(this, "myuserpool", new UserPoolProps {
    // ...
    Mfa = Mfa.REQUIRED,
    MfaSecondFactor = new MfaSecondFactor {
        Sms = true,
        Otp = true,
        Email = false
    }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
cognito.NewUserPool(this, jsii.String("myuserpool"), &UserPoolProps{
	// ...
	Mfa: cognito.Mfa_REQUIRED,
	MfaSecondFactor: &MfaSecondFactor{
		Sms: jsii.Boolean(true),
		Otp: jsii.Boolean(true),
		Email: jsii.Boolean(false),
	},
})

Properties ​

emailoptionalbooleanemailoptionalboolemailoptionalBooleanEmailoptionalboolEmailoptional*bool = false #
The MFA token is sent to the user via EMAIL.

To enable email-based MFA, set email property to the Amazon SES email-sending configuration and set feturePlan to FeaturePlan.ESSENTIALS or FeaturePlan.PLUS

otpbooleanotpboolotpBooleanOtpboolOtp*bool = false required #
The MFA token is a time-based one time password that is generated by a hardware or software token.
smsbooleansmsboolsmsBooleanSmsboolSms*bool = true required #
The MFA token is sent to the user via SMS to their verified phone numbers.