cloud-foundation-fabric/modules/projects-data-source
Wiktor Niesiobędzki 1a657b31d3 Bump beta provider to 4.48
This is the first version that supports `gateway_api_config` block
2023-01-29 15:50:24 +01:00
..
README.md Fix tests 2022-12-18 20:37:16 +01:00
main.tf Add module for retrieving all projects/folders under a specific parent (recursively). 2022-03-07 22:02:18 +01:00
outputs.tf Fix variable/output sort check 2022-11-21 13:17:55 +01:00
variables.tf Fix variable/output sort check 2022-11-21 13:17:55 +01:00
versions.tf Bump beta provider to 4.48 2023-01-29 15:50:24 +01:00

README.md

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     = "./fabric/modules/projects-data-source"
  parent     = "organizations/123456789"
}

output "projects" {
  value = module.my-org.projects
}

output "folders" {
  value = module.my-org.folders
}

# tftest skip (uses data sources)

My dev projects based on parent and label

module "my-dev" {
  source = "./fabric/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 (uses data sources)

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.