[docs] App construct does not show "construction properties", first section is "member properties" and is easy to misinterpret
See original GitHub issueI’m trying to set my account and region at the App level so that all my stacks inherit from it as in the docs. However, when I log the instantiated App, account and region are undefined. In the source, it seems that the props are unsupported.
At minimum, the docs are out of date. However…
I’m pulling account and region from the CDK env vars (CDK_DEFAULT_ACCOUNT, CDK_DEFAULT_REGION). So even if App no longer supports setting them, my stacks should be picking them up anyway. Yet I get the following error:
Error: Cannot retrieve value from context provider hosted-zone 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)
I’m going back to configuring on the Stack-level, but I figured this still warrants looking into.
Reproduction Steps
import {App, Stack} from '@aws-cdk/core';
const account = process.env.CDK_DEFAULT_ACCOUNT;
const region = process.env.CDK_DEFAULT_REGION;
const app = new App({account, region});
const stack = new Stack(app, 'Stack', {});
console.log({account, region}); // { account: '215531866295', region: 'us-east-1' }
Environment
- CLI Version : 1.60.0
- Framework Version: 1.60.0
- Node.js Version: 14.8.0
- OS : OSX
- Language (Version): JS
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Neta was right and I’m wrong. I fell into the same trap as the original poster, mistaking the set of “member properties” for a set of “construction properties”.
Normally a construct renders the construction properties as the first table but not for
App
since it’s the only construct that doesn’t follow the standard construct signature of(scope, id, props)
.This is a docs problem:
App
should show the table of construction properties, and the fact that both sets of properties are called “properties” doesn’t help AT ALLThis issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.