Skip to content

Alternative solution for Cognito domain name issues #9

@athewsey

Description

@athewsey

As noted in the README, this sample currently needs a cognito_domain configuration set for any subsequent re-deployments after the initial - the reasons being:

  1. This sample generates a non-reproducible random domain name at synthesis time via Math.random - so every re-synthesis will change the target domain name, and
  2. CloudFormation does not seem to support updating the name of a previously-deployed domain.

There's not much we can do about (2), but I think (1) could actually be fixable.

Instead of Math.random, we could use logic similar to CDK's internal generatePhysicalName utility to create a name which is deterministically repeatable but still conditional on the target [account ID, region, stack name, and fully-qualified construct node path] for the deployment.

With this solution (assuming we need to keep the prefix as part of the generated domain name), users would only potentially run in to trouble if they modified the prefix after first deployment. If having the prefix on the URL isn't necessary then even that constraint could be dropped I think: Changing any of the other things (stack name, node path, etc) should normally result in destroying & re-creating the Cognito pool anyway.

The main trade-off would be that users would see an error if they try to synthesize a region- or account-agnostic CloudFormation template from the app - but I'm not actually sure if that's possible today either? Certainly seems a much less common use-case than just deploying the CDK to a target environment.


I'm currently testing a tentative solution - happy to raise in PR if it'd be of interest & seems to work

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions