Class CfnNatGateway

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.98.0 (build 00b106d)", date="2024-05-24T02:42:36.831Z") @Stability(Stable) public class CfnNatGateway extends CfnResource implements IInspectable, ITaggable
Specifies a network address translation (NAT) gateway in the specified subnet.

You can create either a public NAT gateway or a private NAT gateway. The default is a public NAT gateway. If you create a public NAT gateway, you must specify an elastic IP address.

With a NAT gateway, instances in a private subnet can connect to the internet, other AWS services, or an on-premises network using the IP address of the NAT gateway. For more information, see NAT gateways in the Amazon VPC User Guide .

If you add a default route ( AWS::EC2::Route resource) that points to a NAT gateway, specify the NAT gateway ID for the route's NatGatewayId property.

When you associate an Elastic IP address or secondary Elastic IP address with a public NAT gateway, the network border group of the Elastic IP address must match the network border group of the Availability Zone (AZ) that the public NAT gateway is in. Otherwise, the NAT gateway fails to launch. You can see the network border group for the AZ by viewing the details of the subnet. Similarly, you can view the network border group for the Elastic IP address by viewing its details. For more information, see Allocate an Elastic IP address 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.*;
 CfnNatGateway cfnNatGateway = CfnNatGateway.Builder.create(this, "MyCfnNatGateway")
         .subnetId("subnetId")
         // the properties below are optional
         .allocationId("allocationId")
         .connectivityType("connectivityType")
         .maxDrainDurationSeconds(123)
         .privateIpAddress("privateIpAddress")
         .secondaryAllocationIds(List.of("secondaryAllocationIds"))
         .secondaryPrivateIpAddressCount(123)
         .secondaryPrivateIpAddresses(List.of("secondaryPrivateIpAddresses"))
         .tags(List.of(CfnTag.builder()
                 .key("key")
                 .value("value")
                 .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

    • CfnNatGateway

      protected CfnNatGateway(software.amazon.jsii.JsiiObjectRef objRef)
    • CfnNatGateway

      protected CfnNatGateway(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • CfnNatGateway

      @Stability(Stable) public CfnNatGateway(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CfnNatGatewayProps 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.
    • getAttrNatGatewayId

      @Stability(Stable) @NotNull public String getAttrNatGatewayId()
      The ID of the NAT gateway.
    • 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
    • getSubnetId

      @Stability(Stable) @NotNull public String getSubnetId()
      The ID of the subnet in which the NAT gateway is located.
    • setSubnetId

      @Stability(Stable) public void setSubnetId(@NotNull String value)
      The ID of the subnet in which the NAT gateway is located.
    • getAllocationId

      @Stability(Stable) @Nullable public String getAllocationId()
      [Public NAT gateway only] The allocation ID of the Elastic IP address that's associated with the NAT gateway.
    • setAllocationId

      @Stability(Stable) public void setAllocationId(@Nullable String value)
      [Public NAT gateway only] The allocation ID of the Elastic IP address that's associated with the NAT gateway.
    • getConnectivityType

      @Stability(Stable) @Nullable public String getConnectivityType()
      Indicates whether the NAT gateway supports public or private connectivity.
    • setConnectivityType

      @Stability(Stable) public void setConnectivityType(@Nullable String value)
      Indicates whether the NAT gateway supports public or private connectivity.
    • getMaxDrainDurationSeconds

      @Stability(Stable) @Nullable public Number getMaxDrainDurationSeconds()
      The maximum amount of time to wait (in seconds) before forcibly releasing the IP addresses if connections are still in progress.
    • setMaxDrainDurationSeconds

      @Stability(Stable) public void setMaxDrainDurationSeconds(@Nullable Number value)
      The maximum amount of time to wait (in seconds) before forcibly releasing the IP addresses if connections are still in progress.
    • getPrivateIpAddress

      @Stability(Stable) @Nullable public String getPrivateIpAddress()
      The private IPv4 address to assign to the NAT gateway.
    • setPrivateIpAddress

      @Stability(Stable) public void setPrivateIpAddress(@Nullable String value)
      The private IPv4 address to assign to the NAT gateway.
    • getSecondaryAllocationIds

      @Stability(Stable) @Nullable public List<String> getSecondaryAllocationIds()
      Secondary EIP allocation IDs.
    • setSecondaryAllocationIds

      @Stability(Stable) public void setSecondaryAllocationIds(@Nullable List<String> value)
      Secondary EIP allocation IDs.
    • getSecondaryPrivateIpAddressCount

      @Stability(Stable) @Nullable public Number getSecondaryPrivateIpAddressCount()
      [Private NAT gateway only] The number of secondary private IPv4 addresses you want to assign to the NAT gateway.
    • setSecondaryPrivateIpAddressCount

      @Stability(Stable) public void setSecondaryPrivateIpAddressCount(@Nullable Number value)
      [Private NAT gateway only] The number of secondary private IPv4 addresses you want to assign to the NAT gateway.
    • getSecondaryPrivateIpAddresses

      @Stability(Stable) @Nullable public List<String> getSecondaryPrivateIpAddresses()
      Secondary private IPv4 addresses.
    • setSecondaryPrivateIpAddresses

      @Stability(Stable) public void setSecondaryPrivateIpAddresses(@Nullable List<String> value)
      Secondary private IPv4 addresses.
    • getTagsRaw

      @Stability(Stable) @Nullable public List<CfnTag> getTagsRaw()
      The tags for the NAT gateway.
    • setTagsRaw

      @Stability(Stable) public void setTagsRaw(@Nullable List<CfnTag> value)
      The tags for the NAT gateway.