Class CfnSubnet

All Implemented Interfaces:
IConstruct, IDependable, IInspectable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:39.036Z") @Stability(Stable) public class CfnSubnet extends CfnResource implements IInspectable
A CloudFormation AWS::EC2::Subnet.

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:

 // The code below shows an example of how to instantiate this type.
 // The values are placeholders you should change.
 import software.amazon.awscdk.services.ec2.*;
 Object privateDnsNameOptionsOnLaunch;
 CfnSubnet cfnSubnet = CfnSubnet.Builder.create(this, "MyCfnSubnet")
         .vpcId("vpcId")
         // the properties below are optional
         .assignIpv6AddressOnCreation(false)
         .availabilityZone("availabilityZone")
         .availabilityZoneId("availabilityZoneId")
         .cidrBlock("cidrBlock")
         .enableDns64(false)
         .ipv6CidrBlock("ipv6CidrBlock")
         .ipv6Native(false)
         .mapPublicIpOnLaunch(false)
         .outpostArn("outpostArn")
         .privateDnsNameOptionsOnLaunch(privateDnsNameOptionsOnLaunch)
         .tags(List.of(CfnTag.builder()
                 .key("key")
                 .value("value")
                 .build()))
         .build();
 
  • 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 Construct scope, @NotNull String id, @NotNull CfnSubnetProps props)
      Create a new AWS::EC2::Subnet.

      Parameters:
      scope -
      • scope in which this resource is defined.
      This parameter is required.
      id -
      • scoped id of the resource.
      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:.

      { "Fn::GetAtt" : [ "mySubnet", "AvailabilityZone" ] }

    • getAttrIpv6CidrBlocks

      @Stability(Stable) @NotNull public List<String> getAttrIpv6CidrBlocks()
      The IPv6 CIDR blocks that are associated with the subnet, such as [ 2001:db8:1234:1a00::/64 ] .
    • 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()
      Any tags assigned to the subnet.
    • getPrivateDnsNameOptionsOnLaunch

      @Stability(Stable) @NotNull 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.

      For more information, see Amazon EC2 instance hostname types in the Amazon Elastic Compute Cloud User Guide .

      Available options:

      • EnableResourceNameDnsAAAARecord (true | false)
      • EnableResourceNameDnsARecord (true | false)
      • HostnameType (ip-name | resource-name)
    • setPrivateDnsNameOptionsOnLaunch

      @Stability(Stable) public void setPrivateDnsNameOptionsOnLaunch(@NotNull 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.

      For more information, see Amazon EC2 instance hostname types in the Amazon Elastic Compute Cloud User Guide .

      Available options:

      • EnableResourceNameDnsAAAARecord (true | false)
      • EnableResourceNameDnsARecord (true | false)
      • HostnameType (ip-name | resource-name)
    • getVpcId

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

      If you update this property, you must also update the CidrBlock property.

    • setVpcId

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

      If you update this property, you must also update the CidrBlock property.

    • 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 .

      If you specify AssignIpv6AddressOnCreation , you must also specify Ipv6CidrBlock .

    • 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 .

      If you specify AssignIpv6AddressOnCreation , you must also specify Ipv6CidrBlock .

    • 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 .

      If you specify AssignIpv6AddressOnCreation , you must also specify Ipv6CidrBlock .

    • getAvailabilityZone

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

      If you update this property, you must also update the CidrBlock property.

    • setAvailabilityZone

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

      If you update this property, you must also update the CidrBlock property.

    • 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.

      If you update this property, we create a new subnet, and then delete the existing one.

    • setCidrBlock

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

      If you update this property, we create a new subnet, and then delete the existing one.

    • 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.

      For more information, see DNS64 and NAT64 in the Amazon Virtual Private Cloud User Guide .

    • 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.

      For more information, see DNS64 and NAT64 in the Amazon Virtual Private Cloud User Guide .

    • 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.

      For more information, see DNS64 and NAT64 in the Amazon Virtual Private Cloud User Guide .

    • getIpv6CidrBlock

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

      If you specify AssignIpv6AddressOnCreation , you must also specify Ipv6CidrBlock .

    • setIpv6CidrBlock

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

      If you specify AssignIpv6AddressOnCreation , you must also specify Ipv6CidrBlock .

    • getIpv6Native

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

      For more information, see Subnet basics in the Amazon Virtual Private Cloud User Guide .

    • setIpv6Native

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

      For more information, see Subnet basics in the Amazon Virtual Private Cloud User Guide .

    • setIpv6Native

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

      For more information, see Subnet basics in the Amazon Virtual Private Cloud User Guide .

    • 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.