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
Labels
needs-triage
This issue or PR still needs to be triaged.
❓ 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:
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
Other information
CDK doctor shows that the environment values are set as expected
ℹ️ CDK Version: 1.36.0 (build 47c9919)
ℹ️ AWS environment variables:
ℹ️ CDK environment variables:
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 =
The text was updated successfully, but these errors were encountered: