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

env parameter of cdk.Stack constructor seems to be ignored #2841

Closed
dhx-mike-palandra opened this issue Jun 12, 2019 · 8 comments
Closed

env parameter of cdk.Stack constructor seems to be ignored #2841

dhx-mike-palandra opened this issue Jun 12, 2019 · 8 comments
Assignees
Labels
bug This issue is a bug. duplicate This issue is a duplicate. language/python Related to Python bindings management/devenv Related to CDK development/build environment

Comments

@dhx-mike-palandra
Copy link

Describe the bug
env parameter of cdk.Stack constructor seems to be ignored. Apologies if I overlooked something obvious.

To Reproduce

  1. Initialize a new python CDK project
    cdk init --language python

  2. ./cdk_test/cdk_test_stack.py: initialize any construct/resource in the sample stack class; e.g.
    sns.Topic(self, 'CdkTestTopic')

  3. app.py: initialize the stack with an explicit region that differs from your default; e.g.

app = cdk.App()
env = cdk.Environment(region='us-east-2')
stack = CdkTestStack(app, 'my-cdk-test', env=env)

Expected behavior
Relevant cdk commands that interact with CloudFormation (e.g., diff, deploy, destroy, etc.) should operate on the region specified above in app.py. In my case, they did not.

Version:

  • OS: cpe:/o:fedoraproject:fedora:30
  • Programming Language: Python 3.7.3
  • CDK Version: 0.34.0 (build 523807c)
@dhx-mike-palandra dhx-mike-palandra added the bug This issue is a bug. label Jun 12, 2019
@made2591
Copy link
Contributor

I think this is discussed in #2866 - by the way, a temporary fix should be already present (line 515) here) ... but I didn't understand exactly why it doesn't work 🤔

@NGL321 NGL321 added the needs-triage This issue or PR still needs to be triaged. label Jun 17, 2019
@NGL321 NGL321 added language/python Related to Python bindings management/devenv Related to CDK development/build environment duplicate This issue is a duplicate. and removed needs-triage This issue or PR still needs to be triaged. labels Jun 26, 2019
@NGL321
Copy link
Contributor

NGL321 commented Jun 26, 2019

Hi @dhx-mike-palandra!

It looks like @made2591 linked a duplicate issue that has since been resolved.
Please confirm if this fixed your problem so we can either close this issue, or readdress the problem.

Thanks!

@NGL321 NGL321 self-assigned this Jun 26, 2019
@NGL321 NGL321 added closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Jun 26, 2019
@dhx-mike-palandra
Copy link
Author

Thanks for following up. I tested again with the latest CDK release:

$ cdk --version
0.36.0 (build 6d38487)

Unfortunately, the issue still persists; i.e. despite an explicit region specification of "us-east-2", issuing "cdk deploy" creates a stack in my default region (which is not us-east-2).

@eladb
Copy link
Contributor

eladb commented Jun 26, 2019

Can you please share some code for a minimal repro?

@eladb
Copy link
Contributor

eladb commented Jun 26, 2019

Oh, just saw that you provided one... Are you propagating kwargs from your stack to the base Stack?

@dhx-mike-palandra
Copy link
Author

No; I was not. I just corrected that and tried again, and the stack indeed is created in us-east-2. Sorry for not catching that earlier. Thanks for your advice. Take care.

@eladb
Copy link
Contributor

eladb commented Jun 26, 2019

No worries, just made the same mistake myself in a little python app I am working on :-)

@NGL321 NGL321 removed closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Jun 26, 2019
@shearn89
Copy link
Contributor

Just for future googlers - I just bumped into this on CDK 2.8. I was referencing the region/account passed in via env as self.env.region in my stack. Turns out that you need to reference them as self.region! Took me a few minutes to work out, doh!

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. duplicate This issue is a duplicate. language/python Related to Python bindings management/devenv Related to CDK development/build environment
Projects
None yet
Development

No branches or pull requests

5 participants