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 Error when calling vpc.lookup "Cannot retrieve value from context provider vpc-provider since account/region are not specified at the stack level" #7701

Closed
philhorrocks opened this issue Apr 30, 2020 · 1 comment
Labels
needs-triage This issue or PR still needs to be triaged.

Comments

@philhorrocks
Copy link

❓ General Issue

I have set the props env values for the stack but still get the error. **Cannot retrieve value from context provider vpc-provider since account/region are not specified at the stack level. I have set the env properties and these appear to be set (confirmed by CDK doctor.

ℹ️ CDK environment variables:

  • CDK_DEFAULT_ACCOUNT = 11111111111
  • CDK_DEFAULT_REGION = eu-west-2

also setting the env props in the stack call:

env: { account: '1111111111', region: 'eu-west-2' },

The Question

CDK doctor shows that my default CDK variables are set and also have the .env properties set to pass to the stack props. However, I still seem to be getting the error

Cannot retrieve value from context provider vpc-provider since account/region are not specified at the stack level. Either configure "env" with explicit account and region when you define your stack, or use the environment variables "CDK_DEFAULT_ACCOUNT" and "CDK_DEFAULT_REGION" to inherit environment information from the CLI (not recommended for production stacks)
Subprocess exited with error 1

props call:

const InfraDataRefresh_UAT = new InfraDataRefreshStack(app, 'InfraDataRefreshStackDemo',

//parameters

{
env: { account: '1111111111', region: 'eu-west-2' },
accountA: "development-account",
accountB: "uat-account",
database1: "database-refresh"

});

Environment

  • CDK CLI Version: 1.36
  • Module Version: 1.36
  • OS: OSX
  • **Language: TypeScript

Other information

CDK doctor shows that the environment values are set as expected

ℹ️ CDK Version: 1.36.0 (build 47c9919)
ℹ️ AWS environment variables:

  • AWS_SESSION_TOKEN =
  • AWS_DEFAULT_REGION = eu-west-2
  • AWS_SECRET_ACCESS_KEY =
  • AWS_DEFAULT_PROFILE = development-dev
  • AWS_ACCESS_KEY_ID =
  • AWS_SECURITY_TOKEN =
  • AWS_SDK_LOAD_CONFIG = 1
    ℹ️ CDK environment variables:
  • CDK_DEFAULT_ACCOUNT =
  • CDK_DEFAULT_REGION = eu-west-2

Profile <source_profile>:

I also a wrapper script to call the STS token service, followed by cdk command. This sets my AWS credentials and account. This seems to work fine and I can use this to select the environment/AWS profile I require. The AWS config file uses a source_profile and then assumes the role of the account. These profiles are then linked to a root MFA account. Running a cdk diff --profile alone with out the script does not work, as there are no credentials for that profile, they are all linked to the source_profile =

@philhorrocks philhorrocks added the needs-triage This issue or PR still needs to be triaged. label Apr 30, 2020
@philhorrocks
Copy link
Author

This can be closed. Its now working and looks like it was the script I was using to create the STS tokens.

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

No branches or pull requests

1 participant