-
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
Allow getting projects by organization/folder #2958
Comments
Out of curiosity, what kind of use cases would you use this for? This is available under the https://cloud.google.com/resource-manager/reference/rest/v1/projects/list API, but searching could have unintended consequences- what if a new project with a display name that matches is added, for example? |
The use case is to apply similar resources within a folder: e.g. I have To clarify implementation: This would be similar to what AWS provider has for subnets: https://www.terraform.io/docs/providers/aws/d/subnet_ids.html It's true that data "google_projects" "dev" {
organization = "org"
folder = "folder/path/to/it"
labels = ["dev"]
} I want to be able to get a list of project IDs and then I can go do things with them. |
Heya, this is great and will fit like a glove for the module bundles I've been writing. Ideally we would create a pre-defined GCP folder structure w/ their given projects in it and control it all using terraform's google_project and google_folder. That way, a person using these modules will only need to state the project name once, have everything provisioned like so and the subsequent modules like, create me a GCP VPC, create me a GKE cluster, create me a cloudSQL instance, etc could all benefit of using this datasource to fetch it's proper |
Thanks for the insight! I'm looking at implementing this so it could be configured like so: data "google_projects" "my-org-projects" {
filter = "parent.id:012345678910 lifecycleState:DELETE_REQUESTED"
}
data "google_project" "deletion-candidate" {
project_id = "${data.google_projects.my-org-projects.projects.0.project_id}"
} Directly exposing the Does this match both of your expectations/use cases? |
@rileykarson what would work if we count interpolate variables in the filters. Do you know wether or not that possible? |
Oh yup! Interpolations will work as you'd expect, including the dependency graph if you're using a resource in your config. For an example, using an data "google_projects" "my-org-projects" {
filter = "parent.id:${var.organization_id} lifecycleState:DELETE_REQUESTED"
}
data "google_project" "deletion-candidate" {
project_id = "${data.google_projects.my-org-projects.projects.0.project_id}"
} |
Perfect! sign me up 'cause I'm on board! |
Done! This will be available in |
Oh man! Thats awesome!
…On March 4, 2019 at 19:08:24, Riley Karson ***@***.***) wrote:
Done! This will be available in 2.2.0.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2958 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AF163Xq3cBZ8CJwKMFA2HIh_GONOCsR_ks5vTZlYgaJpZM4aY2_j>
.
|
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
Community Note
Description
Currently project data source only supports getting a project by ID. But it would be nice to be able to find a project using organization/folder in case the ID is not known right away. As shown here: https://cloud.google.com/resource-manager/docs/creating-managing-folders
Seems like this should be possible since
folder_id
andorg_id
are already used in the read functionNew or Affected Resource(s)
Potential Terraform Configuration
References
The text was updated successfully, but these errors were encountered: