cloud-foundation-fabric/modules/projects-data-source
Julio Castillo 1a3bb25917 Update provider version (needed for dns logging support). 2022-10-25 12:15:02 +02:00
..
README.md Test documentation examples in the examples/ folder 2022-09-06 17:46:09 +02: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 Add module for retrieving all projects/folders under a specific parent (recursively). 2022-03-07 22:02:18 +01:00
variables.tf Add module for retrieving all projects/folders under a specific parent (recursively). 2022-03-07 22:02:18 +01:00
versions.tf Update provider version (needed for dns logging support). 2022-10-25 12:15:02 +02: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

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

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.