Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cdk-cloudfront-authorization] user-pool-domain lambda generates invalid config #211

Open
elliotsegler opened this issue May 26, 2024 · 0 comments

Comments

@elliotsegler
Copy link

elliotsegler commented May 26, 2024

The user-pool-domain lambda is generating invalid configuration.json which contain a busted domain name like below

{
domainName: "2b7f08a6.auth.async () => {
    if (runtimeConfig.region === void 0) {
      throw new Error("Region is missing from runtimeConfig");
    }
    const region = runtimeConfig.region;
    if (typeof region === "string") {
      return region;
    }
    return region();
  }.amazoncognito.com",
 }

I believe the faulting line is this one:

return userPool.CustomDomain ?? `${userPool.Domain}.auth.${COGNITO_CLIENT.config.region}.amazoncognito.com`;

the COGNITO_CLIENT.config.region which is a CognitoIdentityProviderClientResolvedConfig is able to return either a string, or a Provider<string>. The latter returns the promise of a string.

I'm not sure of the motivation behind using the resolved config, but seeing as we're feeding it from environment variables I suggest accessing that instead, because handling the choice of a string or a promise seems like unnecessary effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant