Aws-cdk: Cognito: CustomDomainConfig property is ignored

Created on 23 Jan 2020  路  3Comments  路  Source: aws/aws-cdk

I'm not able to set up a custom domain name for a cognito user pool using C# SDK.

Reproduction Steps

This is the CDK code that is failing for me:

new CfnUserPoolDomain(this, "authClientDomain", new CfnUserPoolDomainProps
{
     UserPoolId = userPool.UserPoolId,
     Domain = "login.mydomain.com",
     CustomDomainConfig = new { CertificateArn = cognitoCertificate.CertificateArn },
});

I can see that CustomDomainConfig is ignored (it is not in the yaml produced by cdk synth) and I get a deployment error because CDK thinks I'm trying to customize a sub-domain.

Error Log

 3/5 | 5:03:47 PM | CREATE_FAILED        | AWS::Cognito::UserPoolDomain         | authClientDomain The domain name contains an invalid character. Domain names can only contain lower-case letters, numbers, and hyphens. Please enter a different name that follows this format: ^[a-z0-9](?:[a-z0-9\-]{0,61}[a-z0-9])?$ (Service: AWSCognitoIdentityProviderService; Status Code: 400; Error Code: InvalidParameterException; Request ID: 18d55cb7-224d-4245-b0d8-f71773d950d4)

Environment

  • CLI Version : 1.21.1 (build 842cc5f)
  • OS : Windows 10
  • Language : C#, .NET Core 3.0

This is :bug: Bug Report

@aws-cdaws-cognito bug closing-soon

All 3 comments

One workaround that worked for me is to use an escape hatch by overriding the user pool domain resource property:

var cfnUserPoolDomain = new CfnUserPoolDomain() { ... };
cfnUserPoolDomain.AddPropertyOverride("CustomDomainConfig.CertificateArn", cognitoCertificate.CertificateArn);

I really appreciate that AWS team put this option into the CDK!

@eloskutov -

It seems that this might be a problem with your code (I'm not a c# expert).

Change the last line on your code snippet to below. I got it to work this way.

CustomDomainConfig = new CfnUserPoolDomain.CustomDomainConfigTypeProperty { CertificateArn = cognitoCertificate.CertificateArn }

Can you confirm this fixes it?

Yes, that fixes the problem. I haven't noticed that class in the SDK. Thank you, @nija-at!

Was this page helpful?
0 / 5 - 0 ratings