Environment

class aws_cdk.core.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.accountId 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 concerete region information and will cause this stack to emit synthesis errors. Default: Aws.accountId 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 concerete 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:

# Passing a replication bucket created in a different stack.
app = App()
replication_stack = Stack(app, "ReplicationStack",
    env=Environment(
        region="us-west-1"
    )
)
key = kms.Key(replication_stack, "ReplicationKey")
replication_bucket = s3.Bucket(replication_stack, "ReplicationBucket",
    # like was said above - replication buckets need a set physical name
    bucket_name=PhysicalName.GENERATE_IF_NEEDED,
    encryption_key=key
)

# later...
codepipeline.Pipeline(replication_stack, "Pipeline",
    cross_region_replication_buckets={
        "us-west-1": replication_bucket
    }
)

Attributes

account

The AWS account ID for this environment.

This can be either a concrete value such as 585191031104 or Aws.accountId 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 concerete region information and will cause this stack to emit synthesis errors.

Default

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

Return type

Optional[str]

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 concerete region information and will cause this stack to emit synthesis errors.

Default

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

Return type

Optional[str]