Class CfnSubnet
- All Implemented Interfaces:
IEnvironmentAware,IInspectable,ITaggable,ISubnetRef,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
For an IPv4 only subnet, specify an IPv4 CIDR block. If the VPC has an IPv6 CIDR block, you can create an IPv6 only subnet or a dual stack subnet instead. For an IPv6 only subnet, specify an IPv6 CIDR block. For a dual stack subnet, specify both an IPv4 CIDR block and an IPv6 CIDR block.
For more information, see Subnets for your VPC in the Amazon VPC User Guide .
Example:
import software.amazon.awscdk.cdk.lambdalayer.kubectl.v33.KubectlV33Layer;
Vpc vpc;
public void associateSubnetWithV6Cidr(Vpc vpc, Number count, ISubnet subnet) {
CfnSubnet cfnSubnet = (CfnSubnet)subnet.getNode().getDefaultChild();
cfnSubnet.getIpv6CidrBlock() = Fn.select(count, Fn.cidr(Fn.select(0, vpc.getVpcIpv6CidrBlocks()), 256, (128 - 64).toString()));
cfnSubnet.getAssignIpv6AddressOnCreation() = true;
}
// make an ipv6 cidr
CfnVPCCidrBlock ipv6cidr = CfnVPCCidrBlock.Builder.create(this, "CIDR6")
.vpcId(vpc.getVpcId())
.amazonProvidedIpv6CidrBlock(true)
.build();
// connect the ipv6 cidr to all vpc subnets
Number subnetcount = 0;
ISubnet[] subnets = vpc.publicSubnets.concat(vpc.getPrivateSubnets());
for (Object subnet : subnets) {
// Wait for the ipv6 cidr to complete
subnet.node.addDependency(ipv6cidr);
associateSubnetWithV6Cidr(vpc, subnetcount, subnet);
subnetcount = subnetcount + 1;
}
Cluster cluster = Cluster.Builder.create(this, "hello-eks")
.version(KubernetesVersion.V1_33)
.vpc(vpc)
.ipFamily(IpFamily.IP_V6)
.vpcSubnets(List.of(SubnetSelection.builder().subnets(vpc.getPublicSubnets()).build()))
.kubectlLayer(new KubectlV33Layer(this, "kubectl"))
.build();
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceSpecifies the state of VPC Block Public Access (BPA).static final classA fluent builder forCfnSubnet.static interfaceSpecifies the options for instance hostnames.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.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.services.ec2.ISubnetRef
ISubnetRef.Jsii$Default, ISubnetRef.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.ITaggable
ITaggable.Jsii$Default, ITaggable.Jsii$Proxy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe CloudFormation resource type name for this resource class. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCfnSubnet(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedCfnSubnet(software.amazon.jsii.JsiiObjectRef objRef) CfnSubnet(software.constructs.Construct scope, String id, CfnSubnetProps props) -
Method Summary
Modifier and TypeMethodDescriptionstatic ISubnetReffromSubnetId(software.constructs.Construct scope, String id, String subnetId) Creates a new ISubnetRef from a subnetId.Indicates whether a network interface created in this subnet receives an IPv6 address.The Availability Zone of this subnet.The Availability Zone ID of this subnet.The IPv4 CIDR blocks that are associated with the subnet.The IPv6 CIDR blocks that are associated with the subnet.The ID of the network ACL that is associated with the subnet's VPC, such asacl-5fb85d36.The Amazon Resource Name (ARN) of the Outpost.The ID of the subnet.The ID of the subnet's VPC, such asvpc-11ad4878.The Availability Zone of the subnet.The AZ ID of the subnet.The IPv4 CIDR block assigned to the subnet.Indicates whether DNS queries made to the Amazon-provided DNS Resolver in this subnet should return synthetic IPv6 addresses for IPv4-only destinations.Indicates the device position for local network interfaces in this subnet.An IPv4 IPAM pool ID for the subnet.An IPv4 netmask length for the subnet.The IPv6 CIDR block.An IPv6 IPAM pool ID for the subnet.Indicates whether this is an IPv6 only subnet.An IPv6 netmask length for the subnet.Indicates whether instances launched in this subnet receive a public IPv4 address.The Amazon Resource Name (ARN) of the Outpost.The hostname type for EC2 instances launched into this subnet and how DNS A and AAAA record queries to the instances should be handled.A reference to a Subnet resource.getTags()Tag Manager which manages the tags for this resource.Any tags assigned to the subnet.getVpcId()The ID of the VPC the subnet is in.voidinspect(TreeInspector inspector) Examines the CloudFormation resource and discloses attributes.renderProperties(Map<String, Object> props) voidIndicates whether a network interface created in this subnet receives an IPv6 address.voidIndicates whether a network interface created in this subnet receives an IPv6 address.voidsetAvailabilityZone(String value) The Availability Zone of the subnet.voidsetAvailabilityZoneId(String value) The AZ ID of the subnet.voidsetCidrBlock(String value) The IPv4 CIDR block assigned to the subnet.voidsetEnableDns64(Boolean value) Indicates whether DNS queries made to the Amazon-provided DNS Resolver in this subnet should return synthetic IPv6 addresses for IPv4-only destinations.voidsetEnableDns64(IResolvable value) Indicates whether DNS queries made to the Amazon-provided DNS Resolver in this subnet should return synthetic IPv6 addresses for IPv4-only destinations.voidsetEnableLniAtDeviceIndex(Number value) Indicates the device position for local network interfaces in this subnet.voidsetIpv4IpamPoolId(String value) An IPv4 IPAM pool ID for the subnet.voidsetIpv4NetmaskLength(Number value) An IPv4 netmask length for the subnet.voidsetIpv6CidrBlock(String value) The IPv6 CIDR block.voidsetIpv6IpamPoolId(String value) An IPv6 IPAM pool ID for the subnet.voidsetIpv6Native(Boolean value) Indicates whether this is an IPv6 only subnet.voidsetIpv6Native(IResolvable value) Indicates whether this is an IPv6 only subnet.voidsetIpv6NetmaskLength(Number value) An IPv6 netmask length for the subnet.voidsetMapPublicIpOnLaunch(Boolean value) Indicates whether instances launched in this subnet receive a public IPv4 address.voidIndicates whether instances launched in this subnet receive a public IPv4 address.voidsetOutpostArn(String value) The Amazon Resource Name (ARN) of the Outpost.voidThe hostname type for EC2 instances launched into this subnet and how DNS A and AAAA record queries to the instances should be handled.voidsetTagsRaw(List<CfnTag> value) Any tags assigned to the subnet.voidThe ID of the VPC the subnet is in.Methods inherited from class software.amazon.awscdk.CfnResource
addDeletionOverride, addDependency, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getAtt, getCfnOptions, getCfnResourceType, getEnv, getMetadata, getUpdatedProperites, getUpdatedProperties, isCfnResource, obtainDependencies, obtainResourceDependencies, removeDependency, replaceDependency, shouldSynthesize, toString, validatePropertiesMethods inherited from class software.amazon.awscdk.CfnRefElement
getRefMethods inherited from class software.amazon.awscdk.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalIdMethods inherited from class software.constructs.Construct
getNode, isConstructMethods 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.constructs.IConstruct
getNodeMethods inherited from interface software.amazon.awscdk.IEnvironmentAware
getEnvMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
-
-
Constructor Details
-
CfnSubnet
protected CfnSubnet(software.amazon.jsii.JsiiObjectRef objRef) -
CfnSubnet
protected CfnSubnet(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
CfnSubnet
@Stability(Stable) public CfnSubnet(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CfnSubnetProps props) - Parameters:
scope- Scope in which this resource is defined. This parameter is required.id- Construct identifier for this resource (unique in its scope). This parameter is required.props- Resource properties. This parameter is required.
-
-
Method Details
-
fromSubnetId
@Stability(Stable) @NotNull public static ISubnetRef fromSubnetId(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String subnetId) Creates a new ISubnetRef from a subnetId.- Parameters:
scope- This parameter is required.id- This parameter is required.subnetId- This parameter is required.
-
inspect
Examines the CloudFormation resource and discloses attributes.- Specified by:
inspectin interfaceIInspectable- Parameters:
inspector- tree inspector to collect and process attributes. This parameter is required.
-
renderProperties
@Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String, Object> props) - Overrides:
renderPropertiesin classCfnResource- Parameters:
props- This parameter is required.
-
getAttrAvailabilityZone
The Availability Zone of this subnet.For example,
us-east-1a. -
getAttrAvailabilityZoneId
The Availability Zone ID of this subnet.For example,
use1-az1. -
getAttrBlockPublicAccessStates
-
getAttrCidrBlock
The IPv4 CIDR blocks that are associated with the subnet. -
getAttrIpv6CidrBlocks
The IPv6 CIDR blocks that are associated with the subnet. -
getAttrNetworkAclAssociationId
The ID of the network ACL that is associated with the subnet's VPC, such asacl-5fb85d36. -
getAttrOutpostArn
The Amazon Resource Name (ARN) of the Outpost. -
getAttrSubnetId
The ID of the subnet. -
getAttrVpcId
The ID of the subnet's VPC, such asvpc-11ad4878. -
getCfnProperties
- Overrides:
getCfnPropertiesin classCfnResource
-
getSubnetRef
A reference to a Subnet resource.- Specified by:
getSubnetRefin interfaceISubnetRef
-
getTags
Tag Manager which manages the tags for this resource. -
getVpcId
The ID of the VPC the subnet is in. -
setVpcId
The ID of the VPC the subnet is in. -
getAssignIpv6AddressOnCreation
Indicates whether a network interface created in this subnet receives an IPv6 address.The default value is
false.Returns union: either
BooleanorIResolvable -
setAssignIpv6AddressOnCreation
Indicates whether a network interface created in this subnet receives an IPv6 address.The default value is
false. -
setAssignIpv6AddressOnCreation
Indicates whether a network interface created in this subnet receives an IPv6 address.The default value is
false. -
getAvailabilityZone
The Availability Zone of the subnet. -
setAvailabilityZone
The Availability Zone of the subnet. -
getAvailabilityZoneId
The AZ ID of the subnet. -
setAvailabilityZoneId
The AZ ID of the subnet. -
getCidrBlock
The IPv4 CIDR block assigned to the subnet. -
setCidrBlock
The IPv4 CIDR block assigned to the subnet. -
getEnableDns64
Indicates whether DNS queries made to the Amazon-provided DNS Resolver in this subnet should return synthetic IPv6 addresses for IPv4-only destinations.Returns union: either
BooleanorIResolvable -
setEnableDns64
Indicates whether DNS queries made to the Amazon-provided DNS Resolver in this subnet should return synthetic IPv6 addresses for IPv4-only destinations. -
setEnableDns64
Indicates whether DNS queries made to the Amazon-provided DNS Resolver in this subnet should return synthetic IPv6 addresses for IPv4-only destinations. -
getEnableLniAtDeviceIndex
Indicates the device position for local network interfaces in this subnet. -
setEnableLniAtDeviceIndex
Indicates the device position for local network interfaces in this subnet. -
getIpv4IpamPoolId
An IPv4 IPAM pool ID for the subnet. -
setIpv4IpamPoolId
An IPv4 IPAM pool ID for the subnet. -
getIpv4NetmaskLength
An IPv4 netmask length for the subnet. -
setIpv4NetmaskLength
An IPv4 netmask length for the subnet. -
getIpv6CidrBlock
The IPv6 CIDR block. -
setIpv6CidrBlock
The IPv6 CIDR block. -
getIpv6IpamPoolId
An IPv6 IPAM pool ID for the subnet. -
setIpv6IpamPoolId
An IPv6 IPAM pool ID for the subnet. -
getIpv6Native
Indicates whether this is an IPv6 only subnet.Returns union: either
BooleanorIResolvable -
setIpv6Native
Indicates whether this is an IPv6 only subnet. -
setIpv6Native
Indicates whether this is an IPv6 only subnet. -
getIpv6NetmaskLength
An IPv6 netmask length for the subnet. -
setIpv6NetmaskLength
An IPv6 netmask length for the subnet. -
getMapPublicIpOnLaunch
Indicates whether instances launched in this subnet receive a public IPv4 address.The default value is
false.Returns union: either
BooleanorIResolvable -
setMapPublicIpOnLaunch
Indicates whether instances launched in this subnet receive a public IPv4 address.The default value is
false. -
setMapPublicIpOnLaunch
Indicates whether instances launched in this subnet receive a public IPv4 address.The default value is
false. -
getOutpostArn
The Amazon Resource Name (ARN) of the Outpost. -
setOutpostArn
The Amazon Resource Name (ARN) of the Outpost. -
getPrivateDnsNameOptionsOnLaunch
The hostname type for EC2 instances launched into this subnet and how DNS A and AAAA record queries to the instances should be handled. -
setPrivateDnsNameOptionsOnLaunch
The hostname type for EC2 instances launched into this subnet and how DNS A and AAAA record queries to the instances should be handled. -
getTagsRaw
Any tags assigned to the subnet. -
setTagsRaw
Any tags assigned to the subnet.
-