Skip to content
v2.273.0

SubnetSelection Struct ​

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.

Example ​

ts
declare const vpc: ec2.Vpc;

const cluster = new docdb.DatabaseCluster(this, 'Database', {
  masterUser: {
    username: 'myuser',
  },
  instanceType: ec2.InstanceType.of(ec2.InstanceClass.MEMORY5, ec2.InstanceSize.LARGE),
  vpcSubnets: {
    subnetType: ec2.SubnetType.PUBLIC,
  },
  vpc,
  removalPolicy: RemovalPolicy.SNAPSHOT,
  instanceRemovalPolicy: RemovalPolicy.RETAIN,
});

Properties ​

availabilityZonesstring[]availability_zonestyping.List[str]availabilityZonesList<String>AvailabilityZonesstring[]AvailabilityZones*[]*string= no filtering on AZs is done#
Select subnets only in the given AZs.
onePerAzbooleanone_per_azboolonePerAzBooleanOnePerAzboolOnePerAz*bool= false#
If true, return at most one subnet per AZ.
subnetFiltersSubnetFilter[]subnet_filterstyping.List[SubnetFilter]subnetFiltersList<SubnetFilter>SubnetFiltersSubnetFilter[]SubnetFilters*[]SubnetFilter= none#
List of provided subnet filters.
subnetGroupNamestringsubnet_group_namestrsubnetGroupNameStringSubnetGroupNamestringSubnetGroupName*string= Selection by type instead of by …#
Select the subnet group with the given name.
notes · default

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

subnetsISubnet[]subnetstyping.List[ISubnet]subnetsList<ISubnet>SubnetsISubnet[]Subnets*[]ISubnet= Use all subnets in a selected gr…#
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

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

subnetTypeSubnetTypesubnet_typeSubnetTypesubnetTypeSubnetTypeSubnetTypeSubnetTypeSubnetTypeSubnetType= SubnetType.PRIVATE_WITH_EGRESS (…#
Select all subnets of the given type.

At most one of subnetType and subnetGroupName can be supplied.

default

Default: SubnetType.PRIVATE_WITH_EGRESS (or ISOLATED or PUBLIC if there are no PRIVATE_WITH_EGRESS subnets)