Class SubnetV2
java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.Resource
software.amazon.awscdk.services.ec2.alpha.SubnetV2
- All Implemented Interfaces:
IResource,ISubnetV2,ISubnet,ISubnetRef,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
@Generated(value="jsii-pacmak/1.116.0 (build 0eddcff)",
date="2025-10-24T13:34:49.824Z")
@Stability(Experimental)
public class SubnetV2
extends Resource
implements ISubnetV2
(experimental) The SubnetV2 class represents a subnet within a VPC (Virtual Private Cloud) in AWS.
It extends the Resource class and implements the ISubnet interface.
Instances of this class can be used to create and manage subnets within a VpcV2 instance. Subnets can be configured with specific IP address ranges (IPv4 and IPv6), availability zones, and subnet types (e.g., public, private, isolated).
Example:
VpcV2 myVpc = new VpcV2(this, "Vpc");
RouteTable routeTable = RouteTable.Builder.create(this, "RouteTable")
.vpc(myVpc)
.build();
SubnetV2 subnet = SubnetV2.Builder.create(this, "Subnet")
.vpc(myVpc)
.availabilityZone("eu-west-2a")
.ipv4CidrBlock(new IpCidr("10.0.0.0/24"))
.subnetType(SubnetType.PRIVATE_ISOLATED)
.build();
NatGateway natgw = NatGateway.Builder.create(this, "NatGW")
.subnet(subnet)
.vpc(myVpc)
.connectivityType(NatConnectivityType.PRIVATE)
.privateIpAddress("10.0.0.42")
.build();
Route.Builder.create(this, "NatGwRoute")
.routeTable(routeTable)
.destination("0.0.0.0/0")
.target(Map.of("gateway", natgw))
.build();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class(experimental) A fluent builder forSubnetV2.Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.IResource
IResource.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.services.ec2.alpha.ISubnetV2
ISubnetV2.Jsii$Default, ISubnetV2.Jsii$Proxy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String(experimental) Uniquely identifies this class. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSubnetV2(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedSubnetV2(software.amazon.jsii.JsiiObjectRef objRef) SubnetV2(software.constructs.Construct scope, String id, SubnetV2Props props) (experimental) Constructs a new SubnetV2 instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidassociateNetworkAcl(String id, INetworkAcl networkAcl) (experimental) Associate a Network ACL with this subnet.static ISubnetV2fromSubnetV2Attributes(software.constructs.Construct scope, String id, SubnetV2Attributes attrs) (experimental) Import an existing subnet to the VPC.(experimental) The Availability Zone the subnet is located in.software.constructs.IDependable(experimental) Dependencies for internet connectivity This Property exposes the RouteTable-Subnet association so that other resources can depend on it.(experimental) The IPv4 CIDR block for this subnet.(experimental) The IPv6 CIDR Block for this subnet.(experimental) Returns the Network ACL associated with this subnet.(experimental) Return the Route Table associated with this subnet.(experimental) The subnetId for this particular subnet.(experimental) A reference to a Subnet resource.(experimental) The type of subnet (public or private) that this subnet represents.Methods inherited from class software.amazon.awscdk.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResourceMethods inherited from class software.constructs.Construct
getNode, isConstruct, toStringMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.awscdk.IResource
applyRemovalPolicy, getEnv, getStackMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
PROPERTY_INJECTION_ID
(experimental) Uniquely identifies this class.
-
-
Constructor Details
-
SubnetV2
protected SubnetV2(software.amazon.jsii.JsiiObjectRef objRef) -
SubnetV2
protected SubnetV2(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
SubnetV2
@Stability(Experimental) public SubnetV2(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull SubnetV2Props props) (experimental) Constructs a new SubnetV2 instance.- Parameters:
scope- The parent Construct that this resource will be part of. This parameter is required.id- The unique identifier for this resource. This parameter is required.props- The configuration properties for the subnet. This parameter is required.
-
-
Method Details
-
fromSubnetV2Attributes
@Stability(Experimental) @NotNull public static ISubnetV2 fromSubnetV2Attributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull SubnetV2Attributes attrs) (experimental) Import an existing subnet to the VPC.- Parameters:
scope- This parameter is required.id- This parameter is required.attrs- This parameter is required.
-
associateNetworkAcl
@Stability(Experimental) public void associateNetworkAcl(@NotNull String id, @NotNull INetworkAcl networkAcl) (experimental) Associate a Network ACL with this subnet.- Specified by:
associateNetworkAclin interfaceISubnet- Parameters:
id- The unique identifier for this association. This parameter is required.networkAcl- The Network ACL to associate with this subnet. This parameter is required.
-
getAvailabilityZone
(experimental) The Availability Zone the subnet is located in.- Specified by:
getAvailabilityZonein interfaceISubnet
-
getInternetConnectivityEstablished
@Stability(Experimental) @NotNull public software.constructs.IDependable getInternetConnectivityEstablished()(experimental) Dependencies for internet connectivity This Property exposes the RouteTable-Subnet association so that other resources can depend on it.- Specified by:
getInternetConnectivityEstablishedin interfaceISubnet
-
getIpv4CidrBlock
(experimental) The IPv4 CIDR block for this subnet.- Specified by:
getIpv4CidrBlockin interfaceISubnet
-
getNetworkAcl
(experimental) Returns the Network ACL associated with this subnet. -
getRouteTable
(experimental) Return the Route Table associated with this subnet.- Specified by:
getRouteTablein interfaceISubnet
-
getSubnetId
(experimental) The subnetId for this particular subnet.- Specified by:
getSubnetIdin interfaceISubnet
-
getSubnetRef
(experimental) A reference to a Subnet resource.- Specified by:
getSubnetRefin interfaceISubnetRef
-
getIpv6CidrBlock
(experimental) The IPv6 CIDR Block for this subnet.- Specified by:
getIpv6CidrBlockin interfaceISubnetV2
-
getSubnetType
(experimental) The type of subnet (public or private) that this subnet represents.- Specified by:
getSubnetTypein interfaceISubnetV2
-