Environment

class aws_cdk.Environment(*, account=None, region=None)

Bases: object

The deployment environment for a stack.

Parameters:
  • account (Optional[str]) – The AWS account ID for this environment. This can be either a concrete value such as 585191031104 or Aws.ACCOUNT_ID which indicates that account ID will only be determined during deployment (it will resolve to the CloudFormation intrinsic {"Ref":"AWS::AccountId"}). Note that certain features, such as cross-stack references and environmental context providers require concrete region information and will cause this stack to emit synthesis errors. Default: Aws.ACCOUNT_ID which means that the stack will be account-agnostic.

  • region (Optional[str]) – The AWS region for this environment. This can be either a concrete value such as eu-west-2 or Aws.REGION which indicates that account ID will only be determined during deployment (it will resolve to the CloudFormation intrinsic {"Ref":"AWS::Region"}). Note that certain features, such as cross-stack references and environmental context providers require concrete region information and will cause this stack to emit synthesis errors. Default: Aws.REGION which means that the stack will be region-agnostic.

ExampleMetadata:

infused

Example:

import aws_cdk as cdk


app = cdk.App()
stack = cdk.Stack(app, "Stack", env=cdk.Environment(region="us-west-2"))

global_table = dynamodb.TableV2(stack, "GlobalTable",
    partition_key=dynamodb.Attribute(name="pk", type=dynamodb.AttributeType.STRING),
    replicas=[dynamodb.ReplicaTableProps(region="us-east-1")]
)

global_table.add_replica(region="us-east-2", deletion_protection=True)

Attributes

account

The AWS account ID for this environment.

This can be either a concrete value such as 585191031104 or Aws.ACCOUNT_ID which indicates that account ID will only be determined during deployment (it will resolve to the CloudFormation intrinsic {"Ref":"AWS::AccountId"}). Note that certain features, such as cross-stack references and environmental context providers require concrete region information and will cause this stack to emit synthesis errors.

Default:

Aws.ACCOUNT_ID which means that the stack will be account-agnostic.

region

The AWS region for this environment.

This can be either a concrete value such as eu-west-2 or Aws.REGION which indicates that account ID will only be determined during deployment (it will resolve to the CloudFormation intrinsic {"Ref":"AWS::Region"}). Note that certain features, such as cross-stack references and environmental context providers require concrete region information and will cause this stack to emit synthesis errors.

Default:

Aws.REGION which means that the stack will be region-agnostic.