Open dddomin3 opened 4 years ago
Your assessment is correct, it looks like the nat_ips only passed back the input IPs (if any).
How are you looking up the IPs using a data source?
Oh I just build the nat gateway resource, and use the auto-gened name, and pull it up that way.
data "google_compute_address" "my_address" {
name = "foobar"
}
Not a elegant solution, sadly... I know ip labels are supported in the beta provider, if you're looking for guidance for a solution, perhaps leveraging those could work? I'm just speculating, never looked into the provider code directly so definitely take it with a grain of salt.
Got it. I think the most elegant solution would be adding it to the provider (please open an issue here for that).
As an interim solution I'd be happy to review a PR which includes this data source and merges it into the nat IP output.
Provider support needed. https://github.com/hashicorp/terraform-provider-google/issues/7469
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. 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
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.