2.0 KiB
2.0 KiB
Projects Data Source Module
This module extends functionality of google_projects data source by retrieving all the projects and folders under a specific parent
recursively.
A good usage pattern would be when we want all the projects under a specific folder (including nested subfolders) to be included into VPC Service Controls. Instead of manually maintaining the list of project numbers as an input to the vpc-sc
module we can use that module to retrieve all the project numbers dynamically.
Examples
All projects in my org
module "my-org" {
source = "./modules/projects-data-source"
parent = "organizations/123456789"
}
output "projects" {
value = module.my-org.projects
}
output "folders" {
value = module.my-org.folders
}
# tftest skip
My dev projects based on parent and label
module "my-dev" {
source = "./modules/projects-data-source"
parent = "folders/123456789"
filter = "labels.env:DEV lifecycleState:ACTIVE"
}
output "dev-projects" {
value = module.my-dev.projects
}
output "dev-folders" {
value = module.my-dev.folders
}
# tftest skip
Variables
name | description | type | required | default |
---|---|---|---|---|
parent | Parent folder or organization in 'folders/folder_id' or 'organizations/org_id' format. | string |
✓ | |
filter | A string filter as defined in the REST API. | string |
"lifecycleState:ACTIVE" |
Outputs
name | description | sensitive |
---|---|---|
folders | Map of folders attributes keyed by folder id. | |
project_numbers | List of project numbers. | |
projects | Map of projects attributes keyed by projects id. |