关联 AWS CDK 的 EmailConfigurationProperty 与 UserPool

huangapple go评论80阅读模式
英文:

Associate AWS CDK EmailConfigurationProperty with UserPool

问题

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 <somename@company.com>")
            .replyToEmailAddress("Some Name <somename@company.com>")
            .build();

        // Connect 'emailConfigurationProperty' with 'userPool' here
    }
}
英文:

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+&quot;-UserPoolv008&quot;)
				.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(&quot;arn:aws:ses:us-east-1:000000000:identity/my-id&quot;)
				.from(&quot;Some Name &lt;somename@company.com&gt;&quot;)
				.replyToEmailAddress(&quot;Some Name &lt;somename@company.com&gt;&quot;)
				.build();
	}
}

答案1

得分: 0

截至 AWS CDK v1.62.0 版本,UserPool 高级对象没有 EmailConfigurationProperty 的设置器。解决方案是在 CfnUserPool 低级对象上使用设置器。

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/customer_support@company.com")
    .from("customer_support@company.com")
    .replyToEmailAddress("customer_support@company.com")
    .build();

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

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+&quot;-UserPoolv010&quot;)
	.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(&quot;arn:aws:ses:us-east-1:0000000:identity/customer_support@company.com&quot;)
	.from(&quot;customer_support@company.com&quot;)
	.replyToEmailAddress(&quot;customer_support@company.com&quot;)
	.build();

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

huangapple
  • 本文由 发表于 2020年9月11日 20:23:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/63847036.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定