SubnetSelection
- class aws_cdk.aws_ec2.SubnetSelection(*, availability_zones=None, one_per_az=None, subnet_filters=None, subnet_group_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 doneone_per_az (
Optional
[bool
]) – If true, return at most one subnet per AZ. Default: falsesubnet_filters (
Optional
[Sequence
[SubnetFilter
]]) – List of provided subnet filters. Default: - nonesubnet_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, prefersubnetType
. This field does not select individual subnets, it selects all subnets that share the given subnet group name. This is the name supplied insubnetConfiguration
. At most one ofsubnetType
andsubnetGroupName
can be supplied. Default: - Selection by type instead of by namesubnets (
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 withsubnetType
orsubnetGroupName
. 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 ofsubnetType
andsubnetGroupName
can be supplied. Default: SubnetType.PRIVATE_WITH_EGRESS (or ISOLATED or PUBLIC if there are no PRIVATE_WITH_EGRESS subnets)
- ExampleMetadata:
infused
Example:
# vpc: ec2.Vpc cluster = docdb.DatabaseCluster(self, "Database", master_user=docdb.Login( username="myuser" ), instance_type=ec2.InstanceType.of(ec2.InstanceClass.MEMORY5, ec2.InstanceSize.LARGE), vpc_subnets=ec2.SubnetSelection( subnet_type=ec2.SubnetType.PUBLIC ), vpc=vpc, removal_policy=RemovalPolicy.SNAPSHOT, instance_removal_policy=RemovalPolicy.RETAIN )
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
andsubnetGroupName
can be supplied.- Default:
Selection by type instead of by name
- subnet_type
Select all subnets of the given type.
At most one of
subnetType
andsubnetGroupName
can be supplied.- Default:
SubnetType.PRIVATE_WITH_EGRESS (or ISOLATED or PUBLIC if there are no PRIVATE_WITH_EGRESS 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
orsubnetGroupName
.- Default:
Use all subnets in a selected group (all private subnets by default)