Skip to content

Environment defaults and support for relocatable templates #2866

@eladb

Description

@eladb

[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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestA feature should be added or improved.needs-triageThis issue or PR still needs to be triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions