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
,software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
,software.constructs.IDependable
@Generated(value="jsii-pacmak/1.104.0 (build e79254c)",
date="2024-12-11T23:26:43.233Z")
@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
Modifier and TypeClassDescriptionstatic final class
(experimental) A fluent builder forSubnetV2
.Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.IResource
IResource.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.ec2.alpha.ISubnetV2
ISubnetV2.Jsii$Default, ISubnetV2.Jsii$Proxy
-
Constructor Summary
ModifierConstructorDescriptionprotected
SubnetV2
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
SubnetV2
(software.amazon.jsii.JsiiObjectRef objRef) SubnetV2
(software.constructs.Construct scope, String id, SubnetV2Props props) (experimental) Constructs a new SubnetV2 instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
associateNetworkAcl
(String id, INetworkAcl networkAcl) (experimental) Associate a Network ACL with this subnet.static ISubnetV2
fromSubnetV2Attributes
(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) 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, isResource
Methods inherited from class software.constructs.Construct
getNode, isConstruct, toString
Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface software.constructs.IConstruct
getNode
Methods inherited from interface software.amazon.awscdk.IResource
applyRemovalPolicy, getEnv, getStack
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
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:
associateNetworkAcl
in 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:
getAvailabilityZone
in 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:
getInternetConnectivityEstablished
in interfaceISubnet
-
getIpv4CidrBlock
(experimental) The IPv4 CIDR block for this subnet.- Specified by:
getIpv4CidrBlock
in interfaceISubnet
-
getNetworkAcl
(experimental) Returns the Network ACL associated with this subnet. -
getRouteTable
(experimental) Return the Route Table associated with this subnet.- Specified by:
getRouteTable
in interfaceISubnet
-
getSubnetId
(experimental) The subnetId for this particular subnet.- Specified by:
getSubnetId
in interfaceISubnet
-
getIpv6CidrBlock
(experimental) The IPv6 CIDR Block for this subnet.- Specified by:
getIpv6CidrBlock
in interfaceISubnetV2
-
getSubnetType
(experimental) The type of subnet (public or private) that this subnet represents.- Specified by:
getSubnetType
in interfaceISubnetV2
-