Class CfnSubnet

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
All Implemented Interfaces:
IInspectable, ITaggable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.104.0 (build e79254c)", date="2024-11-27T16:50:56.440Z") @Stability(Stable) public class CfnSubnet extends CfnResource implements IInspectable, ITaggable
Specifies a subnet for the specified VPC.

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:

 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_31)
         .vpc(vpc)
         .ipFamily(IpFamily.IP_V6)
         .vpcSubnets(List.of(SubnetSelection.builder().subnets(vpc.getPublicSubnets()).build()))
         .build();
 

See Also:
  • Field Details

    • CFN_RESOURCE_TYPE_NAME

      @Stability(Stable) public static final String 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

    • inspect

      @Stability(Stable) public void inspect(@NotNull TreeInspector inspector)
      Examines the CloudFormation resource and discloses attributes.

      Specified by:
      inspect in interface IInspectable
      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:
      renderProperties in class CfnResource
      Parameters:
      props - This parameter is required.
    • getAttrAvailabilityZone

      @Stability(Stable) @NotNull public String getAttrAvailabilityZone()
      The Availability Zone of this subnet.

      For example, us-east-1a .

    • getAttrAvailabilityZoneId

      @Stability(Stable) @NotNull public String getAttrAvailabilityZoneId()
      The Availability Zone ID of this subnet.

      For example, use1-az1 .

    • getAttrCidrBlock

      @Stability(Stable) @NotNull public String getAttrCidrBlock()
      The IPv4 CIDR blocks that are associated with the subnet.
    • getAttrIpv6CidrBlocks

      @Stability(Stable) @NotNull public List<String> getAttrIpv6CidrBlocks()
      The IPv6 CIDR blocks that are associated with the subnet.
    • getAttrNetworkAclAssociationId

      @Stability(Stable) @NotNull public String getAttrNetworkAclAssociationId()
      The ID of the network ACL that is associated with the subnet's VPC, such as acl-5fb85d36 .
    • getAttrOutpostArn

      @Stability(Stable) @NotNull public String getAttrOutpostArn()
      The Amazon Resource Name (ARN) of the Outpost.
    • getAttrSubnetId

      @Stability(Stable) @NotNull public String getAttrSubnetId()
      The ID of the subnet.
    • getAttrVpcId

      @Stability(Stable) @NotNull public String getAttrVpcId()
      The ID of the subnet's VPC, such as vpc-11ad4878 .
    • getCfnProperties

      @Stability(Stable) @NotNull protected Map<String,Object> getCfnProperties()
      Overrides:
      getCfnProperties in class CfnResource
    • getTags

      @Stability(Stable) @NotNull public TagManager getTags()
      Tag Manager which manages the tags for this resource.
      Specified by:
      getTags in interface ITaggable
    • getVpcId

      @Stability(Stable) @NotNull public String getVpcId()
      The ID of the VPC the subnet is in.
    • setVpcId

      @Stability(Stable) public void setVpcId(@NotNull String value)
      The ID of the VPC the subnet is in.
    • getAssignIpv6AddressOnCreation

      @Stability(Stable) @Nullable public Object getAssignIpv6AddressOnCreation()
      Indicates whether a network interface created in this subnet receives an IPv6 address.

      The default value is false .

    • setAssignIpv6AddressOnCreation

      @Stability(Stable) public void setAssignIpv6AddressOnCreation(@Nullable Boolean value)
      Indicates whether a network interface created in this subnet receives an IPv6 address.

      The default value is false .

    • setAssignIpv6AddressOnCreation

      @Stability(Stable) public void setAssignIpv6AddressOnCreation(@Nullable IResolvable value)
      Indicates whether a network interface created in this subnet receives an IPv6 address.

      The default value is false .

    • getAvailabilityZone

      @Stability(Stable) @Nullable public String getAvailabilityZone()
      The Availability Zone of the subnet.
    • setAvailabilityZone

      @Stability(Stable) public void setAvailabilityZone(@Nullable String value)
      The Availability Zone of the subnet.
    • getAvailabilityZoneId

      @Stability(Stable) @Nullable public String getAvailabilityZoneId()
      The AZ ID of the subnet.
    • setAvailabilityZoneId

      @Stability(Stable) public void setAvailabilityZoneId(@Nullable String value)
      The AZ ID of the subnet.
    • getCidrBlock

      @Stability(Stable) @Nullable public String getCidrBlock()
      The IPv4 CIDR block assigned to the subnet.
    • setCidrBlock

      @Stability(Stable) public void setCidrBlock(@Nullable String value)
      The IPv4 CIDR block assigned to the subnet.
    • getEnableDns64

      @Stability(Stable) @Nullable public Object getEnableDns64()
      Indicates whether DNS queries made to the Amazon-provided DNS Resolver in this subnet should return synthetic IPv6 addresses for IPv4-only destinations.
    • setEnableDns64

      @Stability(Stable) public void setEnableDns64(@Nullable 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.
    • setEnableDns64

      @Stability(Stable) public void setEnableDns64(@Nullable 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.
    • getEnableLniAtDeviceIndex

      @Stability(Stable) @Nullable public Number getEnableLniAtDeviceIndex()
      Indicates the device position for local network interfaces in this subnet.
    • setEnableLniAtDeviceIndex

      @Stability(Stable) public void setEnableLniAtDeviceIndex(@Nullable Number value)
      Indicates the device position for local network interfaces in this subnet.
    • getIpv4IpamPoolId

      @Stability(Stable) @Nullable public String getIpv4IpamPoolId()
      An IPv4 IPAM pool ID for the subnet.
    • setIpv4IpamPoolId

      @Stability(Stable) public void setIpv4IpamPoolId(@Nullable String value)
      An IPv4 IPAM pool ID for the subnet.
    • getIpv4NetmaskLength

      @Stability(Stable) @Nullable public Number getIpv4NetmaskLength()
      An IPv4 netmask length for the subnet.
    • setIpv4NetmaskLength

      @Stability(Stable) public void setIpv4NetmaskLength(@Nullable Number value)
      An IPv4 netmask length for the subnet.
    • getIpv6CidrBlock

      @Stability(Stable) @Nullable public String getIpv6CidrBlock()
      The IPv6 CIDR block.
    • setIpv6CidrBlock

      @Stability(Stable) public void setIpv6CidrBlock(@Nullable String value)
      The IPv6 CIDR block.
    • getIpv6IpamPoolId

      @Stability(Stable) @Nullable public String getIpv6IpamPoolId()
      An IPv6 IPAM pool ID for the subnet.
    • setIpv6IpamPoolId

      @Stability(Stable) public void setIpv6IpamPoolId(@Nullable String value)
      An IPv6 IPAM pool ID for the subnet.
    • getIpv6Native

      @Stability(Stable) @Nullable public Object getIpv6Native()
      Indicates whether this is an IPv6 only subnet.
    • setIpv6Native

      @Stability(Stable) public void setIpv6Native(@Nullable Boolean value)
      Indicates whether this is an IPv6 only subnet.
    • setIpv6Native

      @Stability(Stable) public void setIpv6Native(@Nullable IResolvable value)
      Indicates whether this is an IPv6 only subnet.
    • getIpv6NetmaskLength

      @Stability(Stable) @Nullable public Number getIpv6NetmaskLength()
      An IPv6 netmask length for the subnet.
    • setIpv6NetmaskLength

      @Stability(Stable) public void setIpv6NetmaskLength(@Nullable Number value)
      An IPv6 netmask length for the subnet.
    • getMapPublicIpOnLaunch

      @Stability(Stable) @Nullable public Object getMapPublicIpOnLaunch()
      Indicates whether instances launched in this subnet receive a public IPv4 address.

      The default value is false .

    • setMapPublicIpOnLaunch

      @Stability(Stable) public void setMapPublicIpOnLaunch(@Nullable Boolean value)
      Indicates whether instances launched in this subnet receive a public IPv4 address.

      The default value is false .

    • setMapPublicIpOnLaunch

      @Stability(Stable) public void setMapPublicIpOnLaunch(@Nullable IResolvable value)
      Indicates whether instances launched in this subnet receive a public IPv4 address.

      The default value is false .

    • getOutpostArn

      @Stability(Stable) @Nullable public String getOutpostArn()
      The Amazon Resource Name (ARN) of the Outpost.
    • setOutpostArn

      @Stability(Stable) public void setOutpostArn(@Nullable String value)
      The Amazon Resource Name (ARN) of the Outpost.
    • getPrivateDnsNameOptionsOnLaunch

      @Stability(Stable) @Nullable public Object 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

      @Stability(Stable) public void setPrivateDnsNameOptionsOnLaunch(@Nullable Object value)
      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

      @Stability(Stable) @Nullable public List<CfnTag> getTagsRaw()
      Any tags assigned to the subnet.
    • setTagsRaw

      @Stability(Stable) public void setTagsRaw(@Nullable List<CfnTag> value)
      Any tags assigned to the subnet.