[Only using “region” here, but same applies for account].
stack.region will resolve to: env.region || Aws.region
- Any code that requires a concrete region will check
Token.isUndefined(stack.region), either fall back and return a "relocatable" result (e.g. use Fn::GetAZs) or emit a metadata error and return dummy values for tests.
- If
stack.region is not a concrete value, assembly manifest will indicate any-region in the stack's environment spec (aws://1287239487234/any-region). Same for account.
- If
cdk deploy sees any-region in a stack's environment spec, it will use the default region as configured in the CLI. If a region is not configured for some reason, an error will be reported.
- Remove
Context.getDefaultRegion(). It shouldn't be accessed directly.
User guide and documentation should guide users who wish to synthesize "relocatable" (account/region-agnostic) templates to simply set env: { account: Aws.account, region: Aws.region } when they define their stack. This will result in the above behavior to kick in.
[Only using “region” here, but same applies for account].
stack.regionwill resolve to:env.region || Aws.regionToken.isUndefined(stack.region), either fall back and return a "relocatable" result (e.g. useFn::GetAZs) or emit a metadata error and return dummy values for tests.stack.regionis not a concrete value, assembly manifest will indicateany-regionin the stack's environment spec (aws://1287239487234/any-region). Same for account.cdk deployseesany-regionin a stack's environment spec, it will use the default region as configured in the CLI. If a region is not configured for some reason, an error will be reported.Context.getDefaultRegion(). It shouldn't be accessed directly.User guide and documentation should guide users who wish to synthesize "relocatable" (account/region-agnostic) templates to simply set
env: { account: Aws.account, region: Aws.region }when they define their stack. This will result in the above behavior to kick in.