Data source: aws_nat_gateways#
Provides a list of NAT gateway IDs. This data source can be useful for retrieving a list of NAT gateway IDs to be referenced elsewhere.
Example usage#
Specific example: get all available NAT gateways in the region#
data "aws_nat_gateways" "ngws" {
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#
The arguments of this data source act as filters for querying the available NAT gateways.
filter- (Optional, Block) One or more name/value pairs to use as filters.- Valid values: See supported names and values in EC2 API documentation
tags- (Optional, Map of strings) Key-value pairs. Must exactly match pairs on the required resources.vpc_id- (Optional, String) The ID of the VPC in which the NAT gateways are 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#
In addition to all arguments above, the following attributes are exported:
id- (String) The region.- Example:
ru-msk
- Example:
ids- (List of strings) The list of all the NAT gateway IDs found.