-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NAT gateway with nat_ip_allocate_option=AUTO, no ip address output #7469
Comments
I'm not aware if this information is available anywhere. For an
Is this information available in the API somewhere that you're aware of? |
I think that the solution is to check all external IPs with the purpose of gcloud compute addresses list --filter=purpose=NAT_AUTO --format json | jq -r '.[] | select(.users[] | endswith("/tf-test-router-1")) | .address' |
Hmm- the most viable way of getting access to that in Terraform is probably to add support for a |
That would probably be good enough solution, @rileykarson. If the data "google_compute_global_address" "nat" {
filter = "purpose=NAT_AUTO AND users:(/${google_compute_router.router.name})"
}
output "my_nat_ip" {
value = google_compute_global_address.nat.address
} You can test the gcloud compute addresses list --filter="purpose=NAT_AUTO users:(/tf-test-router-1)" |
Actually, we would need to use data "google_compute_global_addresses" "nat" {
filter = "purpose=NAT_AUTO AND users:(/${google_compute_router.router.name})"
}
data "google_compute_global_address" "nat" {
name = data.google_compute_global_addresses.nat.addresses[0].name
}
output "my_nat_ip" {
value = google_compute_global_address.nat.address
} Interestingly, the |
Whoops- address type mixup on my part, I'd figured that this would use external addresses and not internal ones.
|
Thanks. I just checked the requests |
Signed-off-by: Modular Magician <[email protected]>
Signed-off-by: Modular Magician <[email protected]>
Community Note
modular-magician
user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned tohashibot
, a community member has claimed the issue already.Terraform Version
v0.12.23
Google provider 3.7.0
Affected Resource(s)
Issue summary
When creating a nat gateway with nat_ip_allocate_option=AUTO_ONLY, the nat gateway terraform module does not output the ip addresses that were assigned to the nat gateway. Deriving the ip address that is assigned to the nat gateway would involve a data resource, and doesn’t feel like best practice
I would expect the ip address to be outputted in the nat_ips array. The documentation suggests that this field is ignored if AUTO_ONLY is set, but it’s ambiguous if this extends to the outputted data.
Expected Behavior
I’d either expect there to be a different output for ips outright, or for the nat_ips array to be populated regardless of the nat_ip_allocate_option value
Actual Behavior
Try to get IP address out of
"nat_ips" = []
and see that it's blank.Steps to Reproduce
Create a NAT gateway with terraform. Set
"nat_ip_allocate_option" = "AUTO_ONLY"
. Try to get IP address out of"nat_ips" = []
and see that it's blank.terraform apply
Important Factoids
I have none, but factoids are actually uh...
"an invented fact believed to be true because it appears in print"
References
terraform-google-modules/terraform-google-cloud-nat#37
The text was updated successfully, but these errors were encountered: