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.

Cannot retrieve value from context provider vpc-provider since account/region are not specified at the stack level

See original GitHub issue

Note: for support questions, please first reference our documentation, then use Stackoverflow. This repository’s issues are intended for feature requests and bug reports.

  • I’m submitting a …

    • 🪲 bug report
    • 🚀 feature request
    • 📚 construct library gap
    • ☎️ security issue or vulnerability => Please see policy
    • ❓ support request => Please see note at the top of this template.
  • What is the current behavior? When trying to use ec2.Vpc.fromLookup, and passing { env: { region: “your-region”, account: “your-account-id”} } I get and error when doing cdk list: Cannot retrieve value from context provider vpc-provider since account/region are not specified at the stack level Link to code: https://gist.github.com/mrcustard/828242e3e5b8786776fd0c78d1e74e63

  • What is the expected behavior (or behavior of feature suggested)? I would expect to be able to lookup the vpc and get ec2.IVPc returned

  • Please tell us about your environment:

    • CDK CLI Version: 0.36.0 (build 6d38487)
    • Module Version: 0.36.0
    • OS: OSX Mojave
    • Language: TypeScript
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
jimmyhmillercommented, Jan 23, 2020

In case someone runs into this problem and made the same mistake as me. (@niels1voo it looks like you might have). I had been constructing my own stack and properly passing in the env. But I used the boilerplate and it had its own stack in bin/project-name.ts that was making a stack. I didn’t realize that. Instead of making my own stack, I edited that one to include an environment. That made everything work.

9reactions
hoegertncommented, Sep 9, 2019

@kaihendry you do not have to set these variables. They are set by CDK but you have to use them in den StackProps.

{
	env: {
		account: process.env.CDK_DEFAULT_ACCOUNT,
		region: process.env.CDK_DEFAULT_REGION,
	},
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot retrieve value from context provider ami since account ...
If we pick apart the error, it's saying in order to locate the proper AMIs for your EC2 instances, it needs a region/account...
Read more >
awslabs/aws-cdk - Gitter
JSIIError : Cannot retrieve value from context provider vpc-provider since account/region are not specified at the stack level. Either configure "env" with ...
Read more >
Environments - AWS Cloud Development Kit (AWS CDK) v2
An environment is the target AWS account and Region into which the stack is intended to be deployed. The Region is specified using...
Read more >
How to become an infrastructure-as-code ninja, using AWS CDK
cdk synth Cannot retrieve value from context provider vpc-provider since account/region are not specified at the stack level.
Read more >
ServiceCatalog AWS CDK 2.0 : r/aws_cdk - Reddit
Cannot retrieve value from context provider vpc-provider since account/region are not specified at the stack level.
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