Skip to content

Data source: aws_nat_gateway#

Provides information about a NAT gateway.

Example usage#

Specific example: get a NAT gateway by the ID of its VPC#

variable vpc_id {}

data "aws_nat_gateway" "selected" {
  vpc_id = var.vpc_id
}

Specific example: get a NAT gateway by its tags#

data "aws_nat_gateway" "selected" {
  tags = {
    Name = "gw NAT"
  }
}

Argument reference#

The arguments of this data source act as filters for querying the available NAT gateway.

~> Note The given filters must exactly match the resource whose data will be exported as attributes.

  • filter - (Optional, Block) One or more name/value pairs to use as filters.
  • id - (Optional, String) The ID of the NAT gateway.
  • state - (Optional, String) The current state of the NAT gateway.
    • Valid values: available, deleting, failed, pending
  • tags - (Optional, Map of strings) Key-value pairs. Must exactly match pairs on the required resource.
  • vpc_id - (Optional, String) The ID of the VPC in which the NAT gateway is located.

filter#

  • name - (Required, String) The name of the filter.
    • Constraints: Filter names are case-sensitive
  • values - (Required, List of strings) One or more filter values.
    • Constraints: Filter values are case-sensitive

Attribute reference#

If any fields are missing from the configuration, then this data source will populate them with data for the selected NAT gateway.

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

  • auto_provision_zones - (String) The state of automatic Elastic IP address allocation for each availability zone.
    • Valid values: disabled, enabled
  • availability_mode - (String) The availability mode of the NAT gateway.
    • Valid values: regional
  • connectivity_type - (String) The connectivity type of the NAT gateway.
    • Valid values: public
  • nat_gateway_addresses - (Block) The set of addresses of the NAT gateway.

nat_gateway_addresses#

Each block has the following structure:

  • allocation_id - (String) The allocation ID of the Elastic IP address.
  • association_id - (String) The association ID of the Elastic IP address.
  • availability_zone - (String) The availability zone of the Elastic IP address.
  • is_primary - (Boolean) Indicates whether the Elastic IP address is the primary address of the NAT gateway.
  • private_ip - (String) The private IP address.
  • public_ip - (String) The public IP address.
  • status - (String) The status of the Elastic IP address.