Skip to content
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

data google_compute_addresses with filter #10212

Comments

@stephenc
Copy link

stephenc commented Oct 1, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment. If the issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Description

In order to configure a kubernetes cluster with allowed networks, I need to know the status:IN_USE addresses of purpose:NAT_AUTO

the google_compute_address data source only fetches a single named address, but as these are AUTO_IP and created in a separate project, I cannot find them as I cannot predict what names they will have

New or Affected Resource(s)

  • google_compute_addresses

Potential Terraform Configuration

# The use case is where the project you want to query the addresses from is either
# managed by another team with their own separate terraform state or
# not managed by terraform :-(
# We assume that the user running terraform has read permissions for the network 
# addresses in the project they need to query... or they are impersonating a
# service account that has read permissions
#
# resolved value is a list of objects with the same format as "google_compute_address"
data "google_compute_addresses" "vpn-nat-addresses" {
  project = "the-project-that-has-the-vpn"
  filter = "purpose:'NAT_AUTO' AND status:'IN_USE'"
}

...

resource "google_container_cluster" "my-cluster" {
  ...
  master_authorized_networks_config {
    dynamic "cidr_blocks" {
      for_each = data.google_compute_addresses.vpn-nat-addresses
      content {
        cidr_block = "${cidr_blocks.value.address}/32"
      }
    }    
  }
  ...
}

References

  • gcloud compute addresses list --project ... -- filter ... returns the information required but gets ugly to wire up with an external provider if using service account impersonation
@rileykarson
Copy link
Collaborator

See #8255, this is blocked on that.

@melinath
Copy link
Collaborator

b/243811404

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.