arvancloud_vpc_nat_gateways (Data Source)
Lists VPC NAT Gateways with optional filtering by VPC ID, region, subnet ID, or Elastic IP ID.
Example Usage
# List all NAT gateways.
data "arvancloud_vpc_nat_gateways" "all" {}
output "all_nat_gateways" {
value = data.arvancloud_vpc_nat_gateways.all.nat_gateways
}
# List NAT gateways in a specific VPC.
data "arvancloud_vpc_nat_gateways" "vpc_nat_gateways" {
vpc_id = arvancloud_vpc.example.id
}
output "vpc_natgw_count" {
value = length(data.arvancloud_vpc_nat_gateways.vpc_nat_gateways.nat_gateways)
}
output "vpc_natgw_public_ips" {
value = [for ng in data.arvancloud_vpc_nat_gateways.vpc_nat_gateways.nat_gateways : ng.public_ip]
}
# List NAT gateways in a specific region.
data "arvancloud_vpc_nat_gateways" "ir_central" {
region = "ir-central1"
}
output "ir_central_natgw_ids" {
value = [for ng in data.arvancloud_vpc_nat_gateways.ir_central.nat_gateways : ng.id]
}
# List NAT gateways in a specific subnet.
data "arvancloud_vpc_nat_gateways" "subnet_natgws" {
subnet_id = arvancloud_vpc_subnet.example.id
}
output "subnet_natgws" {
value = data.arvancloud_vpc_nat_gateways.subnet_natgws.nat_gateways
}
# Filter by multiple criteria: VPC and region.
data "arvancloud_vpc_nat_gateways" "filtered" {
vpc_id = arvancloud_vpc_vpc.app_vpc.id
region = "ir-central1"
}
output "filtered_natgw_details" {
value = {
for ng in data.arvancloud_vpc_nat_gateways.filtered.nat_gateways : ng.id => {
name = ng.name
public_ip = ng.public_ip
subnet_id = ng.subnet_id
elastic_ip_id = ng.elastic_ip_id
state = ng.state
}
}
}
# Find NAT gateway by Elastic IP.
data "arvancloud_vpc_nat_gateways" "by_elastic_ip" {
elastic_ip_id = arvancloud_vpc_elastic_ip.example.id
}
output "natgw_by_eip" {
value = length(data.arvancloud_vpc_nat_gateways.by_elastic_ip.nat_gateways) > 0 ? data.arvancloud_vpc_nat_gateways.by_elastic_ip.nat_gateways[0] : null
}
Schema
Optional
elastic_ip_id(String) Filter NAT gateways by Elastic IP ID.region(String) Filter NAT gateways by region (e.g.,ir-central1).subnet_id(String) Filter NAT gateways by subnet ID.vpc_id(String) Filter NAT gateways by VPC ID.
Read-Only
id(String) Identifier of the datasource.nat_gateways(Attributes List) List of NAT gateways matching the filter criteria. (see below for nested schema)
Nested Schema for nat_gateways
Read-Only:
created_at(String) Timestamp when the NAT gateway was created.elastic_ip_id(String) ID of the Elastic IP associated with the NAT gateway.id(String) Unique identifier of the NAT gateway.name(String) Name of the NAT gateway.public_ip(String) Public IP address of the NAT gateway.region(String) Region where the NAT gateway is located.state(String) Current state of the NAT gateway.subnet_id(String) ID of the subnet where the NAT gateway is deployed.vpc_id(String) ID of the VPC this NAT gateway belongs to.