I'm not able to set up a custom domain name for a cognito user pool using C# SDK.
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.
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)
This is :bug: Bug Report
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!