0
votes

How do I associate EmailConfigurationProperty with UserPool? I have both objects configured, but do not see the path to connect them.

https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-cognito.UserPool.html

https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-cognito.CfnUserPool.EmailConfigurationProperty.html

public class CdkStackMain extends Stack {

    public CdkStackMain(final Construct scope, final String id, final StackProps props, StackMode stackMode) {
        super(scope, id, props);

        // other objects created here

        UserPool userPool = UserPool.Builder.create(this, myAppName+"-UserPoolv008")
                .userPoolName(myAppName)
                .autoVerify(autoVerifiedAttrs)
                .accountRecovery(AccountRecovery.EMAIL_AND_PHONE_WITHOUT_MFA)
                .selfSignUpEnabled(true)
                .passwordPolicy(passwordPolicy)
                .signInCaseSensitive(false)
                .standardAttributes(standardAtts)
                .signInAliases(signinAliases)
                .build();

        EmailConfigurationProperty emailConfigurationProperty = EmailConfigurationProperty.builder()
                .sourceArn("arn:aws:ses:us-east-1:000000000:identity/my-id")
                .from("Some Name <[email protected]>")
                .replyToEmailAddress("Some Name <[email protected]>")
                .build();
    }
}
1
AWS CDK supports many languages, so having 'Java' in the title was helpful, because the solutions in Python or TypeScript are different from the solution in Java.KevinB

1 Answers

0
votes

As of AWS CDK v1.62.0 the UserPool high level object does not have a setter for the EmailConfigurationProperty. The solution is to use the setter on the CfnUserPool low level object.

UserPool userPool = UserPool.Builder.create(this, myAppName+"-UserPoolv010")
    .userPoolName(myAppName)
    .autoVerify(autoVerifiedAttrs)
    .accountRecovery(AccountRecovery.EMAIL_AND_PHONE_WITHOUT_MFA)
    .selfSignUpEnabled(true)
    .passwordPolicy(passwordPolicy)
    .signInCaseSensitive(false)
    .standardAttributes(standardAtts)
    .signInAliases(signinAliases)
    .lambdaTriggers(userPoolTriggers)
    .build();

EmailConfigurationProperty emailConfigurationProperty = EmailConfigurationProperty.builder()
    .emailSendingAccount(EmailSendingAccountType.DEVELOPER.toString())
    .sourceArn("arn:aws:ses:us-east-1:0000000:identity/[email protected]")
    .from("[email protected]")
    .replyToEmailAddress("[email protected]")
    .build();

CfnUserPool cfnUserPool = (CfnUserPool)userPool.getNode().getDefaultChild();
cfnUserPool.setEmailConfiguration(emailConfigurationProperty);