SubnetSelection

class aws_cdk.aws_ec2.SubnetSelection(*, availability_zones=None, one_per_az=None, subnet_filters=None, subnet_group_name=None, subnet_name=None, subnets=None, subnet_type=None)

Bases: object

Customize subnets that are selected for placement of ENIs.

Constructs that allow customization of VPC placement use parameters of this type to provide placement settings.

By default, the instances are placed in the private subnets.

Parameters:
  • availability_zones (Optional[Sequence[str]]) – Select subnets only in the given AZs. Default: no filtering on AZs is done

  • one_per_az (Optional[bool]) – If true, return at most one subnet per AZ. Default: false

  • subnet_filters (Optional[Sequence[SubnetFilter]]) – List of provided subnet filters. Default: - none

  • subnet_group_name (Optional[str]) – Select the subnet group with the given name. Select the subnet group with the given name. This only needs to be used if you have multiple subnet groups of the same type and you need to distinguish between them. Otherwise, prefer subnetType. This field does not select individual subnets, it selects all subnets that share the given subnet group name. This is the name supplied in subnetConfiguration. At most one of subnetType and subnetGroupName can be supplied. Default: - Selection by type instead of by name

  • subnet_name (Optional[str]) – (deprecated) Alias for subnetGroupName. Select the subnet group with the given name. This only needs to be used if you have multiple subnet groups of the same type and you need to distinguish between them.

  • subnets (Optional[Sequence[ISubnet]]) – Explicitly select individual subnets. Use this if you don’t want to automatically use all subnets in a group, but have a need to control selection down to individual subnets. Cannot be specified together with subnetType or subnetGroupName. Default: - Use all subnets in a selected group (all private subnets by default)

  • subnet_type (Optional[SubnetType]) – Select all subnets of the given type. At most one of subnetType and subnetGroupName can be supplied. Default: SubnetType.PRIVATE_WITH_NAT (or ISOLATED or PUBLIC if there are no PRIVATE_WITH_NAT subnets)

ExampleMetadata:

infused

Example:

# vpc: ec2.Vpc

cluster = docdb.DatabaseCluster(self, "Database",
    master_user=docdb.Login(
        username="myuser",  # NOTE: 'admin' is reserved by DocumentDB
        exclude_characters=""@/:",  # optional, defaults to the set ""@/" and is also used for eventually created rotations
        secret_name="/myapp/mydocdb/masteruser"
    ),
    instance_type=ec2.InstanceType.of(ec2.InstanceClass.R5, ec2.InstanceSize.LARGE),
    vpc_subnets=ec2.SubnetSelection(
        subnet_type=ec2.SubnetType.PUBLIC
    ),
    vpc=vpc
)

Attributes

availability_zones

Select subnets only in the given AZs.

Default:

no filtering on AZs is done

one_per_az

If true, return at most one subnet per AZ.

Default:

false

subnet_filters

List of provided subnet filters.

Default:
  • none

subnet_group_name

Select the subnet group with the given name.

Select the subnet group with the given name. This only needs to be used if you have multiple subnet groups of the same type and you need to distinguish between them. Otherwise, prefer subnetType.

This field does not select individual subnets, it selects all subnets that share the given subnet group name. This is the name supplied in subnetConfiguration.

At most one of subnetType and subnetGroupName can be supplied.

Default:
  • Selection by type instead of by name

subnet_name

(deprecated) Alias for subnetGroupName.

Select the subnet group with the given name. This only needs to be used if you have multiple subnet groups of the same type and you need to distinguish between them.

Deprecated:

Use subnetGroupName instead

Stability:

deprecated

subnet_type

Select all subnets of the given type.

At most one of subnetType and subnetGroupName can be supplied.

Default:

SubnetType.PRIVATE_WITH_NAT (or ISOLATED or PUBLIC if there are no PRIVATE_WITH_NAT subnets)

subnets

Explicitly select individual subnets.

Use this if you don’t want to automatically use all subnets in a group, but have a need to control selection down to individual subnets.

Cannot be specified together with subnetType or subnetGroupName.

Default:
  • Use all subnets in a selected group (all private subnets by default)