-
Notifications
You must be signed in to change notification settings - Fork 545
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Essential Contacts support (#617)
* initial commit - module and example * initial commit - module and example added testing updating test docs update whitespace fixes linting fixes title change cleanup composed essential_contacts submodule in main module whitespace added essential_contacts to variables replace EC list variable with map re-wrote tests * verify version = false * typo Co-authored-by: Bharath KKB <[email protected]> * remove essential contacts from old test suite * update to go test suite * formatting * typo * shortened test command * use example over fixture * remove fixture * typo * remove ruby tests * update go packages * fix example references * better test commands * formatting * update go * import utils * variable description names * var description updates Co-authored-by: Bharath KKB <[email protected]>
- Loading branch information
1 parent
71ea320
commit f89e1a0
Showing
20 changed files
with
1,357 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Essential Contacts | ||
|
||
This example illustrates how to use the essential_contacts submodule to assign emails to specific notification types and languages. | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| billing\_account | Billing account ID. | `string` | n/a | yes | | ||
| folder\_id | The ID of a folder to host this project. | `string` | n/a | yes | | ||
| org\_id | The organization ID. | `string` | n/a | yes | | ||
| project\_id | The GCP project to create Essential Contacts in | `string` | n/a | yes | | ||
| random\_string\_for\_testing | A random string of characters to be appended to resource names to ensure uniqueness | `string` | n/a | yes | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| project\_id | The GCP project with Essential Contacts | | ||
|
||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
module "project-factory" { | ||
source = "../../" | ||
|
||
name = "pf-ci-test-ec-${var.random_string_for_testing}" | ||
random_project_id = true | ||
org_id = var.org_id | ||
folder_id = var.folder_id | ||
billing_account = var.billing_account | ||
|
||
activate_apis = [ | ||
"compute.googleapis.com", | ||
"container.googleapis.com", | ||
"essentialcontacts.googleapis.com" | ||
] | ||
|
||
essential_contacts = { | ||
"[email protected]" = ["ALL"], | ||
"[email protected]" = ["SECURITY", "TECHNICAL"], | ||
"[email protected]" = ["TECHNICAL"] | ||
} | ||
|
||
language_tag = "en-US" | ||
|
||
default_service_account = "DISABLE" | ||
disable_services_on_destroy = false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Copyright 2018 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
output "project_id" { | ||
value = module.project-factory.project_id | ||
description = "The GCP project with Essential Contacts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Copyright 2018 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
variable "project_id" { | ||
type = string | ||
description = "The GCP project to create Essential Contacts in" | ||
} | ||
|
||
variable "org_id" { | ||
type = string | ||
description = "The organization ID." | ||
} | ||
|
||
variable "folder_id" { | ||
type = string | ||
description = "The ID of a folder to host this project." | ||
} | ||
|
||
variable "billing_account" { | ||
type = string | ||
description = "Billing account ID." | ||
} | ||
|
||
variable "random_string_for_testing" { | ||
type = string | ||
description = "A random string of characters to be appended to resource names to ensure uniqueness" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Copyright 2018 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
terraform { | ||
required_version = ">= 0.13" | ||
required_providers { | ||
google = { | ||
source = "hashicorp/google" | ||
version = "~> 4.0" | ||
} | ||
google-beta = { | ||
source = "hashicorp/google-beta" | ||
version = "~> 4.0" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Essential Contacts configuration | ||
|
||
This module uses the [`google_essential_contacts_contact`](https://www.terraform.io/docs/providers/google/r/google_project_service.html) | ||
resource to add contact emails which will receive notification types from Google Cloud, using specified subcription types. | ||
|
||
## Prerequisites | ||
|
||
1. Service account used to run Terraform has permission to administer Essential Contacts: | ||
[`roles/essentialcontacts.admin`](https://cloud.google.com/iam/docs/understanding-roles#other-roles). | ||
2. The target project has the Essential Contacts API enabled `essentialcontacts.googleapis.com ` | ||
|
||
## Example Usage | ||
``` | ||
module "essential_contacts" { | ||
source = "../../modules/essential_contacts" | ||
project_id = var.project_id | ||
essential_contacts = { | ||
"[email protected]" = ["ALL"], | ||
"[email protected]" = ["SECURITY", "TECHNICAL"], | ||
"[email protected]" = ["TECHNICAL"] | ||
} | ||
language_tag = "en-US" | ||
} | ||
``` | ||
|
||
See [examples/essential_contacts](./examples/essential_contacts) for a full example. | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| essential\_contacts | A mapping of users or groups to be assigned as Essential Contacts to the project, specifying a notification category | `map(list(string))` | `{}` | no | | ||
| language\_tag | Language code to be used for essential contacts notifiactions | `string` | n/a | yes | | ||
| project\_id | The GCP project you want to send Essential Contacts notifications for | `any` | n/a | yes | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| essential\_contacts | Essential Contact resources created | | ||
| project\_id | The GCP project you want to enable APIs on | | ||
|
||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/****************************************** | ||
Essential Contact configuration | ||
*****************************************/ | ||
|
||
resource "google_essential_contacts_contact" "contact" { | ||
for_each = var.essential_contacts | ||
|
||
parent = "projects/${var.project_id}" | ||
email = each.key | ||
language_tag = var.language_tag | ||
notification_category_subscriptions = each.value | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
output "essential_contacts" { | ||
description = "Essential Contact resources created" | ||
value = [for contact in google_essential_contacts_contact.contact : contact.name] | ||
} | ||
|
||
output "project_id" { | ||
description = "The GCP project you want to enable APIs on" | ||
value = var.project_id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
variable "project_id" { | ||
description = "The GCP project you want to send Essential Contacts notifications for" | ||
} | ||
|
||
variable "essential_contacts" { | ||
description = "A mapping of users or groups to be assigned as Essential Contacts to the project, specifying a notification category" | ||
type = map(list(string)) | ||
default = {} | ||
} | ||
|
||
variable "language_tag" { | ||
description = "Language code to be used for essential contacts notifiactions" | ||
type = string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
terraform { | ||
required_version = ">= 0.13" | ||
required_providers { | ||
google = { | ||
source = "hashicorp/google" | ||
version = ">= 3.43, <5.0" | ||
} | ||
google-beta = { | ||
source = "hashicorp/google-beta" | ||
version = ">= 3.43, <5.0" | ||
} | ||
} | ||
provider_meta "google" { | ||
module_name = "blueprints/terraform/terraform-google-project-factory:essential_contacts/v11.1.1" | ||
} | ||
provider_meta "google-beta" { | ||
module_name = "blueprints/terraform/terraform-google-project-factory:essential_contacts/v11.1.1" | ||
} | ||
} |
Oops, something went wrong.