Data Source: aws_nat_gateways

This resource can be useful for getting back a list of NAT gateway ids to be referenced elsewhere.

Example Usage

The following returns all NAT gateways in a specified VPC that are marked as available

data "aws_nat_gateways" "ngws" {
  vpc_id = var.vpc_id

  filter {
    name   = "state"
    values = ["available"]
  }
}

data "aws_nat_gateway" "ngw" {
  count = length(data.aws_nat_gateways.ngws.ids)
  id    = tolist(data.aws_nat_gateways.ngws.ids)[count.index]
}

Argument Reference

More complex filters can be expressed using one or more filter sub-blocks, which take the following arguments:

Attribute Reference

This data source exports the following attributes in addition to the arguments above:

Timeouts

Configuration options: