Skip to content

Resource: awsNatGateway

Provides a resource to create a VPC NAT Gateway.

Example Usage

Public NAT

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.natGateway.NatGateway(this, "example", {
  allocationId: "${aws_eip.example.id}",
  depends_on: ["${aws_internet_gateway.example}"],
  subnetId: "${aws_subnet.example.id}",
  tags: {
    Name: "gw NAT",
  },
});

Private NAT

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.natGateway.NatGateway(this, "example", {
  connectivityType: "private",
  subnetId: "${aws_subnet.example.id}",
});

Argument Reference

The following arguments are supported:

  • allocationId - (Optional) The Allocation ID of the Elastic IP address for the gateway. Required for connectivityType of public.
  • connectivityType - (Optional) Connectivity type for the gateway. Valid values are private and public. Defaults to public.
  • privateIp - (Optional) The private IPv4 address to assign to the NAT gateway. If you don't provide an address, a private IPv4 address will be automatically assigned.
  • subnetId - (Required) The Subnet ID of the subnet in which to place the gateway.
  • tags - (Optional) A map of tags to assign to the resource. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - The ID of the NAT Gateway.
  • networkInterfaceId - The ID of the network interface associated with the NAT gateway.
  • publicIp - The Elastic IP address associated with the NAT gateway.
  • tagsAll - A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.

Import

NAT Gateways can be imported using the id, e.g.,

$ terraform import aws_nat_gateway.private_gw nat-05dba92075d71c408