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

cognito.UserPool stack: jsii.errors.JSIIError: There is already a Construct with name '...' in App #6359

Closed
bodokaiser opened this issue Feb 19, 2020 · 1 comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@bodokaiser
Copy link

If I instance a class that extends aws_core.Stack where I instance a aws_cognito.UserPool in the constructor, I get jsii.errors.JSIIError: There is already a Construct with name 'foo-cognito' in App as an error on cdk deploy.

Reproduction Steps

Save to app.py:

from aws_cdk import (
  aws_cognito as cognito,
  core,
)

class CognitoStack(core.Stack):

  def __init__(self, app: core.App, id: str) -> None:
    super().__init__(app, id)

    userpool = cognito.UserPool(app, id,
      sign_in_type=cognito.SignInType.EMAIL,
    )

app = core.App()

CognitoStack(app, "foo-cognito")

app.synth()

Deploy via cdk deploy.

Error Log

cdk deploy
jsii.errors.JavaScriptError: 
  Error: There is already a Construct with name 'foo-cognito' in App
      at ConstructNode.addChild (/private/var/folders/0s/q8yw56tj7r5_clj45bpdpc7r0000gn/T/jsii-kernel-6ZB5Jm/node_modules/@aws-cdk/core/lib/construct.js:408:19)
      at new ConstructNode (/private/var/folders/0s/q8yw56tj7r5_clj45bpdpc7r0000gn/T/jsii-kernel-6ZB5Jm/node_modules/@aws-cdk/core/lib/construct.js:32:24)
      at new Construct (/private/var/folders/0s/q8yw56tj7r5_clj45bpdpc7r0000gn/T/jsii-kernel-6ZB5Jm/node_modules/@aws-cdk/core/lib/construct.js:448:21)
      at new Resource (/private/var/folders/0s/q8yw56tj7r5_clj45bpdpc7r0000gn/T/jsii-kernel-6ZB5Jm/node_modules/@aws-cdk/core/lib/resource.js:13:9)
      at new UserPool (/private/var/folders/0s/q8yw56tj7r5_clj45bpdpc7r0000gn/T/jsii-kernel-6ZB5Jm/node_modules/@aws-cdk/aws-cognito/lib/user-pool.js:134:9)
      at /Users/bodokaiser/.pyenv/versions/3.8.1/Python.framework/Versions/3.8/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7838:49
      at Kernel._wrapSandboxCode (/Users/bodokaiser/.pyenv/versions/3.8.1/Python.framework/Versions/3.8/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:8301:19)
      at Kernel._create (/Users/bodokaiser/.pyenv/versions/3.8.1/Python.framework/Versions/3.8/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7838:26)
      at Kernel.create (/Users/bodokaiser/.pyenv/versions/3.8.1/Python.framework/Versions/3.8/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7585:21)
      at KernelHost.processRequest (/Users/bodokaiser/.pyenv/versions/3.8.1/Python.framework/Versions/3.8/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7372:28)
      at KernelHost.run (/Users/bodokaiser/.pyenv/versions/3.8.1/Python.framework/Versions/3.8/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7312:14)
      at Immediate._onImmediate (/Users/bodokaiser/.pyenv/versions/3.8.1/Python.framework/Versions/3.8/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7315:37)
      at processImmediate (internal/timers.js:456:21)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "app.py", line 20, in <module>
    CognitoStack(app, "foo-cognito")
  File "/Users/bodokaiser/.pyenv/versions/3.8.1/Python.framework/Versions/3.8/lib/python3.8/site-packages/jsii/_runtime.py", line 66, in __call__
    inst = super().__call__(*args, **kwargs)
  File "app.py", line 15, in __init__
    userpool = cognito.UserPool(app, id,
  File "/Users/bodokaiser/.pyenv/versions/3.8.1/Python.framework/Versions/3.8/lib/python3.8/site-packages/jsii/_runtime.py", line 66, in __call__
    inst = super().__call__(*args, **kwargs)
  File "/Users/bodokaiser/.pyenv/versions/3.8.1/Python.framework/Versions/3.8/lib/python3.8/site-packages/aws_cdk/aws_cognito/__init__.py", line 5215, in __init__
    jsii.create(UserPool, self, [scope, id, props])
  File "/Users/bodokaiser/.pyenv/versions/3.8.1/Python.framework/Versions/3.8/lib/python3.8/site-packages/jsii/_kernel/__init__.py", line 224, in create
    response = self.provider.create(
  File "/Users/bodokaiser/.pyenv/versions/3.8.1/Python.framework/Versions/3.8/lib/python3.8/site-packages/jsii/_kernel/providers/process.py", line 333, in create
    return self._process.send(request, CreateResponse)
  File "/Users/bodokaiser/.pyenv/versions/3.8.1/Python.framework/Versions/3.8/lib/python3.8/site-packages/jsii/_kernel/providers/process.py", line 318, in send
    raise JSIIError(resp.error) from JavaScriptError(resp.stack)
jsii.errors.JSIIError: There is already a Construct with name 'coopsaas-cognito' in App
Subprocess exited with error 1

Environment

  • CLI Version : aws-cli/2.0.0 Python/3.8.1 Darwin/19.3.0 botocore/2.0.0dev4 - Framework Version: 1.24.0 (build 6619e36)
  • OS : macOS Catalina
  • Language : English (US)

Other

Possible related or similar issues:


This is 🐛 Bug Report

@bodokaiser bodokaiser added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 19, 2020
@bodokaiser
Copy link
Author

The second argument to cognito.UserPool has to be the name of the user pool and not the stack id. This caused the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant