Merge pull request #201 from terraform-google-modules/jccb/essential-contacts

Add support for essential contacts
This commit is contained in:
Julio Castillo 2021-02-25 07:04:41 +01:00 committed by GitHub
commit c6cf4a00a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 77 additions and 19 deletions

View File

@ -144,6 +144,7 @@ module "folder2" {
| name | description | type | required | default |
|---|---|:---: |:---:|:---:|
| *contacts* | List of essential contacts for this resource. Must be in the form EMAIL -> [NOTIFICATION_TYPES]. Valid notification types are ALL, SUSPENSION, SECURITY, TECHNICAL, BILLING, LEGAL, PRODUCT_UPDATES | <code title="map&#40;list&#40;string&#41;&#41;">map(list(string))</code> | | <code title="">{}</code> |
| *firewall_policies* | Hierarchical firewall policies to *create* in this folder. | <code title="map&#40;map&#40;object&#40;&#123;&#10;description &#61; string&#10;direction &#61; string&#10;action &#61; string&#10;priority &#61; number&#10;ranges &#61; list&#40;string&#41;&#10;ports &#61; map&#40;list&#40;string&#41;&#41;&#10;target_service_accounts &#61; list&#40;string&#41;&#10;target_resources &#61; list&#40;string&#41;&#10;logging &#61; bool&#10;&#125;&#41;&#41;&#41;">map(map(object({...})))</code> | | <code title="">{}</code> |
| *firewall_policy_attachments* | List of hierarchical firewall policy IDs to *attach* to this folder. | <code title="map&#40;string&#41;">map(string)</code> | | <code title="">{}</code> |
| *folder_create* | Create folder. When set to false, uses id to reference an existing folder. | <code title="">bool</code> | | <code title="">true</code> |

View File

@ -71,7 +71,7 @@ resource "google_folder_organization_policy" "boolean" {
folder = local.folder.name
constraint = each.key
dynamic boolean_policy {
dynamic "boolean_policy" {
for_each = each.value == null ? [] : [each.value]
iterator = policy
content {
@ -79,7 +79,7 @@ resource "google_folder_organization_policy" "boolean" {
}
}
dynamic restore_policy {
dynamic "restore_policy" {
for_each = each.value == null ? [""] : []
content {
default = true
@ -92,13 +92,13 @@ resource "google_folder_organization_policy" "list" {
folder = local.folder.name
constraint = each.key
dynamic list_policy {
dynamic "list_policy" {
for_each = each.value.status == null ? [] : [each.value]
iterator = policy
content {
inherit_from_parent = policy.value.inherit_from_parent
suggested_value = policy.value.suggested_value
dynamic allow {
dynamic "allow" {
for_each = policy.value.status ? [""] : []
content {
values = (
@ -113,7 +113,7 @@ resource "google_folder_organization_policy" "list" {
)
}
}
dynamic deny {
dynamic "deny" {
for_each = policy.value.status ? [] : [""]
content {
values = (
@ -131,7 +131,7 @@ resource "google_folder_organization_policy" "list" {
}
}
dynamic restore_policy {
dynamic "restore_policy" {
for_each = each.value.status == null ? [true] : []
content {
default = true
@ -224,3 +224,12 @@ resource "google_logging_folder_exclusion" "logging-exclusion" {
description = "${each.key} (Terraform-managed)"
filter = each.value
}
resource "google_essential_contacts_contact" "contact" {
provider = google-beta
for_each = var.contacts
parent = local.folder.name
email = each.key
language_tag = "en"
notification_category_subscriptions = each.value
}

View File

@ -104,3 +104,9 @@ variable "id" {
type = string
default = null
}
variable "contacts" {
description = "List of essential contacts for this resource. Must be in the form EMAIL -> [NOTIFICATION_TYPES]. Valid notification types are ALL, SUSPENSION, SECURITY, TECHNICAL, BILLING, LEGAL, PRODUCT_UPDATES"
type = map(list(string))
default = {}
}

View File

@ -16,4 +16,7 @@
terraform {
required_version = ">= 0.13.0"
required_providers {
google = "~> 3.57"
}
}

View File

@ -121,6 +121,7 @@ module "org" {
| name | description | type | required | default |
|---|---|:---: |:---:|:---:|
| organization_id | Organization id in organizations/nnnnnn format. | <code title="string&#10;validation &#123;&#10;condition &#61; can&#40;regex&#40;&#34;&#94;organizations&#47;&#91;0-9&#93;&#43;&#34;, var.organization_id&#41;&#41;&#10;error_message &#61; &#34;The organization_id must in the form organizations&#47;nnn.&#34;&#10;&#125;">string</code> | ✓ | |
| *contacts* | List of essential contacts for this resource. Must be in the form EMAIL -> [NOTIFICATION_TYPES]. Valid notification types are ALL, SUSPENSION, SECURITY, TECHNICAL, BILLING, LEGAL, PRODUCT_UPDATES | <code title="map&#40;list&#40;string&#41;&#41;">map(list(string))</code> | | <code title="">{}</code> |
| *custom_roles* | Map of role name => list of permissions to create in this project. | <code title="map&#40;list&#40;string&#41;&#41;">map(list(string))</code> | | <code title="">{}</code> |
| *firewall_policies* | Hierarchical firewall policies to *create* in the organization. | <code title="map&#40;map&#40;object&#40;&#123;&#10;description &#61; string&#10;direction &#61; string&#10;action &#61; string&#10;priority &#61; number&#10;ranges &#61; list&#40;string&#41;&#10;ports &#61; map&#40;list&#40;string&#41;&#41;&#10;target_service_accounts &#61; list&#40;string&#41;&#10;target_resources &#61; list&#40;string&#41;&#10;logging &#61; bool&#10;&#125;&#41;&#41;&#41;">map(map(object({...})))</code> | | <code title="">{}</code> |
| *firewall_policy_attachments* | List of hierarchical firewall policy IDs to *attach* to the organization | <code title="map&#40;string&#41;">map(string)</code> | | <code title="">{}</code> |

View File

@ -120,7 +120,7 @@ resource "google_organization_iam_audit_config" "config" {
for_each = var.iam_audit_config
org_id = local.organization_id_numeric
service = each.key
dynamic audit_log_config {
dynamic "audit_log_config" {
for_each = each.value
iterator = config
content {
@ -135,7 +135,7 @@ resource "google_organization_policy" "boolean" {
org_id = local.organization_id_numeric
constraint = each.key
dynamic boolean_policy {
dynamic "boolean_policy" {
for_each = each.value == null ? [] : [each.value]
iterator = policy
content {
@ -143,7 +143,7 @@ resource "google_organization_policy" "boolean" {
}
}
dynamic restore_policy {
dynamic "restore_policy" {
for_each = each.value == null ? [""] : []
content {
default = true
@ -156,13 +156,13 @@ resource "google_organization_policy" "list" {
org_id = local.organization_id_numeric
constraint = each.key
dynamic list_policy {
dynamic "list_policy" {
for_each = each.value.status == null ? [] : [each.value]
iterator = policy
content {
inherit_from_parent = policy.value.inherit_from_parent
suggested_value = policy.value.suggested_value
dynamic allow {
dynamic "allow" {
for_each = policy.value.status ? [""] : []
content {
values = (
@ -177,7 +177,7 @@ resource "google_organization_policy" "list" {
)
}
}
dynamic deny {
dynamic "deny" {
for_each = policy.value.status ? [] : [""]
content {
values = (
@ -195,7 +195,7 @@ resource "google_organization_policy" "list" {
}
}
dynamic restore_policy {
dynamic "restore_policy" {
for_each = each.value.status == null ? [true] : []
content {
default = true
@ -288,3 +288,12 @@ resource "google_logging_organization_exclusion" "logging-exclusion" {
description = "${each.key} (Terraform-managed)"
filter = each.value
}
resource "google_essential_contacts_contact" "contact" {
provider = google-beta
for_each = var.contacts
parent = var.organization_id
email = each.key
language_tag = "en"
notification_category_subscriptions = each.value
}

View File

@ -133,3 +133,9 @@ variable "logging_exclusions" {
type = map(string)
default = {}
}
variable "contacts" {
description = "List of essential contacts for this resource. Must be in the form EMAIL -> [NOTIFICATION_TYPES]. Valid notification types are ALL, SUSPENSION, SECURITY, TECHNICAL, BILLING, LEGAL, PRODUCT_UPDATES"
type = map(list(string))
default = {}
}

View File

@ -16,4 +16,7 @@
terraform {
required_version = ">= 0.12.6"
required_providers {
google = "~> 3.57"
}
}

View File

@ -135,6 +135,7 @@ module "project-host" {
| name | Project name and id suffix. | <code title="">string</code> | ✓ | |
| *auto_create_network* | Whether to create the default network for the project | <code title="">bool</code> | | <code title="">false</code> |
| *billing_account* | Billing account id. | <code title="">string</code> | | <code title="">null</code> |
| *contacts* | List of essential contacts for this resource. Must be in the form EMAIL -> [NOTIFICATION_TYPES]. Valid notification types are ALL, SUSPENSION, SECURITY, TECHNICAL, BILLING, LEGAL, PRODUCT_UPDATES | <code title="map&#40;list&#40;string&#41;&#41;">map(list(string))</code> | | <code title="">{}</code> |
| *custom_roles* | Map of role name => list of permissions to create in this project. | <code title="map&#40;list&#40;string&#41;&#41;">map(list(string))</code> | | <code title="">{}</code> |
| *iam* | IAM bindings in {ROLE => [MEMBERS]} format. | <code title="map&#40;set&#40;string&#41;&#41;">map(set(string))</code> | | <code title="">{}</code> |
| *iam_additive* | IAM additive bindings in {ROLE => [MEMBERS]} format. | <code title="map&#40;list&#40;string&#41;&#41;">map(list(string))</code> | | <code title="">{}</code> |

View File

@ -169,7 +169,7 @@ resource "google_project_organization_policy" "boolean" {
project = local.project.project_id
constraint = each.key
dynamic boolean_policy {
dynamic "boolean_policy" {
for_each = each.value == null ? [] : [each.value]
iterator = policy
content {
@ -177,7 +177,7 @@ resource "google_project_organization_policy" "boolean" {
}
}
dynamic restore_policy {
dynamic "restore_policy" {
for_each = each.value == null ? [""] : []
content {
default = true
@ -190,13 +190,13 @@ resource "google_project_organization_policy" "list" {
project = local.project.project_id
constraint = each.key
dynamic list_policy {
dynamic "list_policy" {
for_each = each.value.status == null ? [] : [each.value]
iterator = policy
content {
inherit_from_parent = policy.value.inherit_from_parent
suggested_value = policy.value.suggested_value
dynamic allow {
dynamic "allow" {
for_each = policy.value.status ? [""] : []
content {
values = (
@ -211,7 +211,7 @@ resource "google_project_organization_policy" "list" {
)
}
}
dynamic deny {
dynamic "deny" {
for_each = policy.value.status ? [] : [""]
content {
values = (
@ -229,7 +229,7 @@ resource "google_project_organization_policy" "list" {
}
}
dynamic restore_policy {
dynamic "restore_policy" {
for_each = each.value.status == null ? [true] : []
content {
default = true
@ -298,3 +298,12 @@ resource "google_logging_project_exclusion" "logging-exclusion" {
description = "${each.key} (Terraform-managed)"
filter = each.value
}
resource "google_essential_contacts_contact" "contact" {
provider = google-beta
for_each = var.contacts
parent = "projects/${local.project.project_id}"
email = each.key
language_tag = "en"
notification_category_subscriptions = each.value
}

View File

@ -182,3 +182,10 @@ variable "logging_exclusions" {
type = map(string)
default = {}
}
variable "contacts" {
description = "List of essential contacts for this resource. Must be in the form EMAIL -> [NOTIFICATION_TYPES]. Valid notification types are ALL, SUSPENSION, SECURITY, TECHNICAL, BILLING, LEGAL, PRODUCT_UPDATES"
type = map(list(string))
default = {}
}

View File

@ -16,4 +16,7 @@
terraform {
required_version = ">= 0.13.0"
required_providers {
google = "~> 3.57"
}
}