Class Subnet
java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.Resource
software.amazon.awscdk.services.ec2.Subnet
- All Implemented Interfaces:
IResource
,ISubnet
,software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
,software.constructs.IDependable
- Direct Known Subclasses:
PrivateSubnet
,PublicSubnet
@Generated(value="jsii-pacmak/1.103.1 (build bef2dea)",
date="2024-09-11T18:01:15.008Z")
@Stability(Stable)
public class Subnet
extends Resource
implements ISubnet
Represents a new VPC subnet resource.
Example:
Cluster cluster; ApplicationLoadBalancedFargateService loadBalancedFargateService = ApplicationLoadBalancedFargateService.Builder.create(this, "Service") .cluster(cluster) .memoryLimitMiB(1024) .desiredCount(1) .cpu(512) .taskImageOptions(ApplicationLoadBalancedTaskImageOptions.builder() .image(ContainerImage.fromRegistry("amazon/amazon-ecs-sample")) .build()) .taskSubnets(SubnetSelection.builder() .subnets(List.of(Subnet.fromSubnetId(this, "subnet", "VpcISOLATEDSubnet1Subnet80F07FA0"))) .build()) .build();
-
Nested Class Summary
Nested ClassesNested 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.ISubnet
ISubnet.Jsii$Default, ISubnet.Jsii$Proxy
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Subnet
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
Subnet
(software.amazon.jsii.JsiiObjectRef objRef) Subnet
(software.constructs.Construct scope, String id, SubnetProps props) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDefaultInternetRoute
(String gatewayId, software.constructs.IDependable gatewayAttachment) Create a default route that points to a passed IGW, with a dependency on the IGW's attachment to the VPC.void
addDefaultNatRoute
(String natGatewayId) Adds an entry to this subnets route table that points to the passed NATGatewayId.void
addIpv6DefaultEgressOnlyInternetRoute
(String gatewayId) Create a default IPv6 route that points to a passed EIGW.void
addIpv6DefaultInternetRoute
(String gatewayId) Create a default IPv6 route that points to a passed IGW.void
addIpv6Nat64Route
(String natGatewayId) Adds an entry to this subnets route table that points to the passed NATGatewayId.void
addRoute
(String id, AddRouteOptions options) Adds an entry to this subnets route table.void
associateNetworkAcl
(String id, INetworkAcl networkAcl) Associate a Network ACL with this subnet.static ISubnet
fromSubnetAttributes
(software.constructs.Construct scope, String id, SubnetAttributes attrs) static ISubnet
fromSubnetId
(software.constructs.Construct scope, String id, String subnetId) Import existing subnet from id.The Availability Zone the subnet is located in.List<software.constructs.IDependable>
Parts of this VPC subnet.software.constructs.IDependable
Dependable that can be depended upon to force internet connectivity established on the VPC.The IPv4 CIDR block for this subnet.Network ACL associated with this Subnet.The routeTableId attached to this subnet.The subnetId for this particular subnet.The Amazon Resource Name (ARN) of the Outpost for this subnet (if one exists).static Boolean
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
-
Subnet
protected Subnet(software.amazon.jsii.JsiiObjectRef objRef) -
Subnet
protected Subnet(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
Subnet
@Stability(Stable) public Subnet(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull SubnetProps props) - Parameters:
scope
- This parameter is required.id
- This parameter is required.props
- This parameter is required.
-
-
Method Details
-
fromSubnetAttributes
@Stability(Stable) @NotNull public static ISubnet fromSubnetAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull SubnetAttributes attrs) - Parameters:
scope
- This parameter is required.id
- This parameter is required.attrs
- This parameter is required.
-
fromSubnetId
@Stability(Stable) @NotNull public static ISubnet fromSubnetId(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String subnetId) Import existing subnet from id.- Parameters:
scope
- This parameter is required.id
- This parameter is required.subnetId
- This parameter is required.
-
isVpcSubnet
- Parameters:
x
- This parameter is required.
-
addDefaultInternetRoute
@Stability(Stable) public void addDefaultInternetRoute(@NotNull String gatewayId, @NotNull software.constructs.IDependable gatewayAttachment) Create a default route that points to a passed IGW, with a dependency on the IGW's attachment to the VPC.- Parameters:
gatewayId
- the logical ID (ref) of the gateway attached to your VPC. This parameter is required.gatewayAttachment
- the gateway attachment construct to be added as a dependency. This parameter is required.
-
addDefaultNatRoute
Adds an entry to this subnets route table that points to the passed NATGatewayId.- Parameters:
natGatewayId
- The ID of the NAT gateway. This parameter is required.
-
addIpv6DefaultEgressOnlyInternetRoute
Create a default IPv6 route that points to a passed EIGW.- Parameters:
gatewayId
- the logical ID (ref) of the gateway attached to your VPC. This parameter is required.
-
addIpv6DefaultInternetRoute
Create a default IPv6 route that points to a passed IGW.- Parameters:
gatewayId
- the logical ID (ref) of the gateway attached to your VPC. This parameter is required.
-
addIpv6Nat64Route
Adds an entry to this subnets route table that points to the passed NATGatewayId.Uses the known 64:ff9b::/96 prefix.
- Parameters:
natGatewayId
- The ID of the NAT gateway. This parameter is required.
-
addRoute
Adds an entry to this subnets route table.- Parameters:
id
- This parameter is required.options
- This parameter is required.
-
associateNetworkAcl
@Stability(Stable) public void associateNetworkAcl(@NotNull String id, @NotNull INetworkAcl networkAcl) Associate a Network ACL with this subnet.- Specified by:
associateNetworkAcl
in interfaceISubnet
- Parameters:
id
- This parameter is required.networkAcl
- This parameter is required.
-
getAvailabilityZone
The Availability Zone the subnet is located in.- Specified by:
getAvailabilityZone
in interfaceISubnet
-
getDependencyElements
Parts of this VPC subnet. -
getInternetConnectivityEstablished
@Stability(Stable) @NotNull public software.constructs.IDependable getInternetConnectivityEstablished()Dependable that can be depended upon to force internet connectivity established on the VPC.- Specified by:
getInternetConnectivityEstablished
in interfaceISubnet
-
getIpv4CidrBlock
The IPv4 CIDR block for this subnet.- Specified by:
getIpv4CidrBlock
in interfaceISubnet
-
getNetworkAcl
Network ACL associated with this Subnet.Upon creation, this is the default ACL which allows all traffic, except explicit DENY entries that you add.
You can replace it with a custom ACL which denies all traffic except the explicit ALLOW entries that you add by creating a
NetworkAcl
object and callingassociateNetworkAcl()
. -
getRouteTable
The routeTableId attached to this subnet.- Specified by:
getRouteTable
in interfaceISubnet
-
getSubnetAvailabilityZone
-
getSubnetId
The subnetId for this particular subnet.- Specified by:
getSubnetId
in interfaceISubnet
-
getSubnetIpv6CidrBlocks
-
getSubnetNetworkAclAssociationId
-
getSubnetOutpostArn
The Amazon Resource Name (ARN) of the Outpost for this subnet (if one exists). -
getSubnetVpcId
-