question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

env parameter of cdk.Stack constructor seems to be ignored

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
made2591commented, Jun 16, 2019

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 🤔

0reactions
shearn89commented, Jan 18, 2022

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting common AWS CDK issues
When deploying my AWS CDK stack, I receive a NoSuchBucket error. Your AWS environment has not been bootstrapped, and so does not have...
Read more >
awslabs/aws-cdk - Gitter
With a solution like this I'm getting errors when instantiating a stack because of naming collisions: Error: There is already a Construct with...
Read more >
AWS CDK parameter error: Value of property ...
In a nutshell, it looks like a bug in the CDK. The CDK tries to send an array as a parameter to the...
Read more >
AWS CDK Toolkit
Deploys a stack of your CDK app to its environment. During the deployment, the toolkit will output progress indications, similar to what can...
Read more >
Infrastructure Tests with CDK
Stack { constructor(environment: string, scope: cdk. ... here is that each test only tests the properties specified and ignores the rest, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found