Add Alerts, Logging, Channels Factories (#2758)
* WIP: Logging Alerts Factory * Implement Logging Alerts on Remaining Modules * Documentation & FMT * Convert To Multiple Factories * Correct Project * Update Documentation * Update modules/project/alerts-factory.tf Co-authored-by: Julio Castillo <jccb@google.com> * Update fast/stages/0-bootstrap/data/logging-metrics/compliance.yaml Co-authored-by: Julio Castillo <jccb@google.com> * Update Tests, Resources * tests * Fix Tests * Fix formatting * Reformat metric filters * Formatting, reordering, and small fixes * Bring back alerts and metrics documentation * Revert change bootstrap outputs.tf * Fix project notification channel vars and factories * Fix vars and factory for logging alerts * Complete alert variable and factory * Reorder fields * Update readme * Reorder variables * Add schemas, update README, and fix some types * Remove default alerts email from project and project-factory * Move observability factory to a single file * Add outputs to project module * Add factories_config to PF data_defaults and data_overrides * Reorder PF field processing * Revert fast/ to master. We'll do observability stuff in a separate PR * Remove observability from FAST * Remove new FAST tests * Remove unused local * Fix tests --------- Co-authored-by: Julio Castillo <jccb@google.com> Co-authored-by: Ludovico Magnocavallo <ludomagno@google.com>
This commit is contained in:
@@ -440,10 +440,10 @@ update_rules:
|
||||
|
||||
| name | description | type | required | default |
|
||||
|---|---|:---:|:---:|:---:|
|
||||
| [factories_config](variables.tf#L100) | Path to folder with YAML resource description data files. | <code title="object({ folders_data_path = optional(string) projects_data_path = optional(string) budgets = optional(object({ billing_account = string budgets_data_path = string notification_channels = optional(map(any), {}) })) context = optional(object({ folder_ids = optional(map(string), {}) iam_principals = optional(map(string), {}) tag_values = optional(map(string), {}) vpc_host_projects = optional(map(string), {}) }), {}) })">object({…})</code> | ✓ | |
|
||||
| [data_defaults](variables.tf#L17) | Optional default values used when corresponding project data from files are missing. | <code title="object({ billing_account = optional(string) contacts = optional(map(list(string)), {}) labels = optional(map(string), {}) metric_scopes = optional(list(string), []) parent = optional(string) prefix = optional(string) service_encryption_key_ids = optional(map(list(string)), {}) services = optional(list(string), []) shared_vpc_service_config = optional(object({ host_project = string network_users = optional(list(string), []) service_agent_iam = optional(map(list(string)), {}) service_agent_subnet_iam = optional(map(list(string)), {}) service_iam_grants = optional(list(string), []) network_subnet_users = optional(map(list(string)), {}) }), { host_project = null }) storage_location = optional(string) tag_bindings = optional(map(string), {}) service_accounts = optional(map(object({ display_name = optional(string, "Terraform-managed.") iam_self_roles = optional(list(string)) })), {}) vpc_sc = optional(object({ perimeter_name = string perimeter_bridges = optional(list(string), []) is_dry_run = optional(bool, false) })) logging_data_access = optional(map(map(list(string))), {}) })">object({…})</code> | | <code>{}</code> |
|
||||
| [data_merges](variables.tf#L54) | Optional values that will be merged with corresponding data from files. Combines with `data_defaults`, file data, and `data_overrides`. | <code title="object({ contacts = optional(map(list(string)), {}) labels = optional(map(string), {}) metric_scopes = optional(list(string), []) service_encryption_key_ids = optional(map(list(string)), {}) services = optional(list(string), []) tag_bindings = optional(map(string), {}) service_accounts = optional(map(object({ display_name = optional(string, "Terraform-managed.") iam_self_roles = optional(list(string)) })), {}) })">object({…})</code> | | <code>{}</code> |
|
||||
| [data_overrides](variables.tf#L73) | Optional values that override corresponding data from files. Takes precedence over file data and `data_defaults`. | <code title="object({ billing_account = optional(string) contacts = optional(map(list(string))) parent = optional(string) prefix = optional(string) service_encryption_key_ids = optional(map(list(string))) storage_location = optional(string) tag_bindings = optional(map(string)) services = optional(list(string)) service_accounts = optional(map(object({ display_name = optional(string, "Terraform-managed.") iam_self_roles = optional(list(string)) }))) vpc_sc = optional(object({ perimeter_name = string perimeter_bridges = optional(list(string), []) is_dry_run = optional(bool, false) })) logging_data_access = optional(map(map(list(string))), {}) })">object({…})</code> | | <code>{}</code> |
|
||||
| [factories_config](variables.tf#L112) | Path to folder with YAML resource description data files. | <code title="object({ budgets = optional(object({ billing_account = string budgets_data_path = string notification_channels = optional(map(any), {}) })) context = optional(object({ folder_ids = optional(map(string), {}) iam_principals = optional(map(string), {}) tag_values = optional(map(string), {}) vpc_host_projects = optional(map(string), {}) notification_channels = optional(map(string), {}) }), {}) folders_data_path = optional(string) projects_data_path = optional(string) })">object({…})</code> | ✓ | |
|
||||
| [data_defaults](variables.tf#L17) | Optional default values used when corresponding project data from files are missing. | <code title="object({ billing_account = optional(string) contacts = optional(map(list(string)), {}) factories_config = optional(object({ custom_roles = optional(string) observability = optional(string) org_policies = optional(string) quotas = optional(string) }), {}) labels = optional(map(string), {}) metric_scopes = optional(list(string), []) parent = optional(string) prefix = optional(string) service_encryption_key_ids = optional(map(list(string)), {}) services = optional(list(string), []) shared_vpc_service_config = optional(object({ host_project = string network_users = optional(list(string), []) service_agent_iam = optional(map(list(string)), {}) service_agent_subnet_iam = optional(map(list(string)), {}) service_iam_grants = optional(list(string), []) network_subnet_users = optional(map(list(string)), {}) }), { host_project = null }) storage_location = optional(string) tag_bindings = optional(map(string), {}) service_accounts = optional(map(object({ display_name = optional(string, "Terraform-managed.") iam_self_roles = optional(list(string)) })), {}) vpc_sc = optional(object({ perimeter_name = string perimeter_bridges = optional(list(string), []) is_dry_run = optional(bool, false) })) logging_data_access = optional(map(map(list(string))), {}) })">object({…})</code> | | <code>{}</code> |
|
||||
| [data_merges](variables.tf#L60) | Optional values that will be merged with corresponding data from files. Combines with `data_defaults`, file data, and `data_overrides`. | <code title="object({ contacts = optional(map(list(string)), {}) labels = optional(map(string), {}) metric_scopes = optional(list(string), []) service_encryption_key_ids = optional(map(list(string)), {}) services = optional(list(string), []) tag_bindings = optional(map(string), {}) service_accounts = optional(map(object({ display_name = optional(string, "Terraform-managed.") iam_self_roles = optional(list(string)) })), {}) })">object({…})</code> | | <code>{}</code> |
|
||||
| [data_overrides](variables.tf#L79) | Optional values that override corresponding data from files. Takes precedence over file data and `data_defaults`. | <code title="object({ billing_account = optional(string) contacts = optional(map(list(string))) factories_config = optional(object({ custom_roles = optional(string) observability = optional(string) org_policies = optional(string) quotas = optional(string) }), {}) parent = optional(string) prefix = optional(string) service_encryption_key_ids = optional(map(list(string))) storage_location = optional(string) tag_bindings = optional(map(string)) services = optional(list(string)) service_accounts = optional(map(object({ display_name = optional(string, "Terraform-managed.") iam_self_roles = optional(list(string)) }))) vpc_sc = optional(object({ perimeter_name = string perimeter_bridges = optional(list(string), []) is_dry_run = optional(bool, false) })) logging_data_access = optional(map(map(list(string))), {}) })">object({…})</code> | | <code>{}</code> |
|
||||
|
||||
## Outputs
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright 2024 Google LLC
|
||||
* Copyright 2025 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -58,6 +58,37 @@ locals {
|
||||
try(v.contacts, null),
|
||||
var.data_defaults.contacts
|
||||
)
|
||||
factories_config = {
|
||||
custom_roles = try(
|
||||
coalesce(
|
||||
var.data_overrides.factories_config.custom_roles,
|
||||
try(v.factories_config.custom_roles, null),
|
||||
var.data_defaults.factories_config.custom_roles
|
||||
),
|
||||
null
|
||||
)
|
||||
observability = try(
|
||||
coalesce(
|
||||
var.data_overrides.factories_config.observability,
|
||||
try(v.factories_config.observability, null),
|
||||
var.data_defaults.factories_config.observability
|
||||
),
|
||||
null)
|
||||
org_policies = try(
|
||||
coalesce(
|
||||
var.data_overrides.factories_config.org_policies,
|
||||
try(v.factories_config.org_policies, null),
|
||||
var.data_defaults.factories_config.org_policies
|
||||
),
|
||||
null)
|
||||
quotas = try(
|
||||
coalesce(
|
||||
var.data_overrides.factories_config.quotas,
|
||||
try(v.factories_config.quotas, null),
|
||||
var.data_defaults.factories_config.quotas
|
||||
),
|
||||
null)
|
||||
}
|
||||
labels = coalesce(
|
||||
try(v.labels, null),
|
||||
var.data_defaults.labels
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright 2024 Google LLC
|
||||
* Copyright 2025 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,6 +41,7 @@ module "projects" {
|
||||
local.context.folder_ids, each.value.parent, each.value.parent
|
||||
)
|
||||
prefix = each.value.prefix
|
||||
alerts = try(each.value.alerts, null)
|
||||
auto_create_network = try(each.value.auto_create_network, false)
|
||||
compute_metadata = try(each.value.compute_metadata, {})
|
||||
# TODO: concat lists for each key
|
||||
@@ -49,6 +50,15 @@ module "projects" {
|
||||
)
|
||||
default_service_account = try(each.value.default_service_account, "keep")
|
||||
descriptive_name = try(each.value.descriptive_name, null)
|
||||
factories_config = {
|
||||
custom_roles = each.value.factories_config.custom_roles
|
||||
observability = each.value.factories_config.observability
|
||||
org_policies = each.value.factories_config.org_policies
|
||||
quotas = each.value.factories_config.quotas
|
||||
context = {
|
||||
notification_channels = var.factories_config.context.notification_channels
|
||||
}
|
||||
}
|
||||
iam = {
|
||||
for k, v in lookup(each.value, "iam", {}) : k => [
|
||||
for vv in v : try(
|
||||
@@ -93,13 +103,16 @@ module "projects" {
|
||||
each.value.labels, var.data_merges.labels
|
||||
)
|
||||
lien_reason = try(each.value.lien_reason, null)
|
||||
log_scopes = try(each.value.log_scopes, null)
|
||||
logging_data_access = try(each.value.logging_data_access, {})
|
||||
logging_exclusions = try(each.value.logging_exclusions, {})
|
||||
logging_metrics = try(each.value.logging_metrics, null)
|
||||
logging_sinks = try(each.value.logging_sinks, {})
|
||||
metric_scopes = distinct(concat(
|
||||
each.value.metric_scopes, var.data_merges.metric_scopes
|
||||
))
|
||||
org_policies = each.value.org_policies
|
||||
notification_channels = try(each.value.notification_channels, null)
|
||||
org_policies = each.value.org_policies
|
||||
service_encryption_key_ids = merge(
|
||||
each.value.service_encryption_key_ids,
|
||||
var.data_merges.service_encryption_key_ids
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright 2024 Google LLC
|
||||
* Copyright 2025 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,8 +17,14 @@
|
||||
variable "data_defaults" {
|
||||
description = "Optional default values used when corresponding project data from files are missing."
|
||||
type = object({
|
||||
billing_account = optional(string)
|
||||
contacts = optional(map(list(string)), {})
|
||||
billing_account = optional(string)
|
||||
contacts = optional(map(list(string)), {})
|
||||
factories_config = optional(object({
|
||||
custom_roles = optional(string)
|
||||
observability = optional(string)
|
||||
org_policies = optional(string)
|
||||
quotas = optional(string)
|
||||
}), {})
|
||||
labels = optional(map(string), {})
|
||||
metric_scopes = optional(list(string), [])
|
||||
parent = optional(string)
|
||||
@@ -73,8 +79,14 @@ variable "data_merges" {
|
||||
variable "data_overrides" {
|
||||
description = "Optional values that override corresponding data from files. Takes precedence over file data and `data_defaults`."
|
||||
type = object({
|
||||
billing_account = optional(string)
|
||||
contacts = optional(map(list(string)))
|
||||
billing_account = optional(string)
|
||||
contacts = optional(map(list(string)))
|
||||
factories_config = optional(object({
|
||||
custom_roles = optional(string)
|
||||
observability = optional(string)
|
||||
org_policies = optional(string)
|
||||
quotas = optional(string)
|
||||
}), {})
|
||||
parent = optional(string)
|
||||
prefix = optional(string)
|
||||
service_encryption_key_ids = optional(map(list(string)))
|
||||
@@ -100,8 +112,6 @@ variable "data_overrides" {
|
||||
variable "factories_config" {
|
||||
description = "Path to folder with YAML resource description data files."
|
||||
type = object({
|
||||
folders_data_path = optional(string)
|
||||
projects_data_path = optional(string)
|
||||
budgets = optional(object({
|
||||
billing_account = string
|
||||
budgets_data_path = string
|
||||
@@ -110,11 +120,14 @@ variable "factories_config" {
|
||||
}))
|
||||
context = optional(object({
|
||||
# TODO: add KMS keys
|
||||
folder_ids = optional(map(string), {})
|
||||
iam_principals = optional(map(string), {})
|
||||
tag_values = optional(map(string), {})
|
||||
vpc_host_projects = optional(map(string), {})
|
||||
folder_ids = optional(map(string), {})
|
||||
iam_principals = optional(map(string), {})
|
||||
tag_values = optional(map(string), {})
|
||||
vpc_host_projects = optional(map(string), {})
|
||||
notification_channels = optional(map(string), {})
|
||||
}), {})
|
||||
folders_data_path = optional(string)
|
||||
projects_data_path = optional(string)
|
||||
})
|
||||
nullable = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user