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

List usable subnetworks #3490

Open
leg100 opened this issue Apr 25, 2019 · 3 comments
Open

List usable subnetworks #3490

leg100 opened this issue Apr 25, 2019 · 3 comments

Comments

@leg100
Copy link

leg100 commented Apr 25, 2019

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

I would like a data source that returns a list of 'usable subnets', as returned by the command:

gcloud compute networks subnets list-usable

The command is documented here.

This is particularly useful for a 'service project' in a Shared VPC: a user may want to lookup which subnets are available on which a compute instance can be provisioned for their service project.

New or Affected Resource(s)

  • google_compute_usable_subnetworks

Potential Terraform Configuration

data "google_compute_usable_subnetworks" "subnets" {}

resource "google_compute_instance" "default" {
  name         = "test"

  network_interface {
    subnetwork = "${element(data.google_compute_usable_subnets.subnets.*.self_link, 0)}"
  }
}

References

@ghost ghost added the enhancement label Apr 25, 2019
@paddycarver paddycarver added this to the Backlog milestone Dec 10, 2019
modular-magician added a commit to modular-magician/terraform-provider-google that referenced this issue May 20, 2020
modular-magician added a commit that referenced this issue May 20, 2020
@AlfatahB
Copy link
Contributor

b/262517887

@AlfatahB
Copy link
Contributor

I've looked into this issue and it seems like we need to add support for a new datasource google_compute_usable_subnetworks that lists all the usable subnetworks within a project.

  • Product Name: Compute Engine
  • New Datasource Name: google_compute_usable_subnetworks
  • API Docs: List Usable Subnetworks
  • Notes:
    • REST API Endpoint: GET - https://compute.googleapis.com/compute/v1/projects/{project}/aggregated/subnetworks/listUsable
    • This endpoint will retrieve an aggregated list of all usable subnetworks in the specified project.
    • The response will have multiple pages of the items(usable subnetworks) and it will require handling of pagination.
    • I have found a similar datasource google_compute_addresses that lists IP addresses in the project that might be helpful. This datasource has been added in this PR.
    • Similar to google_compute_addresses datasource, this new datasource should be using the filter field so that we can filter resources listed in the response.

@AlfatahB
Copy link
Contributor

If we don't use any filters, the List Usable Subnetworks API operates without any issues. However, I discovered that the filter query parameter is not working as expected. I've tried using the API explorer to pass the filter query parameter, but instead of receiving a filtered result, I'm getting a list of all usable subnetworks. I attempted to add this datasource, which can provide an aggregated list of all usable subnetworks in the project, however in order to make it function, the filter query parameter in the API has to be fixed. This commit contains my implementation of the datasource file, which might be useful for creating this datasource when the filter problem is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants