Skip to content

Commit f16e805

Browse files
daniel-citgtsorbo
andauthored
feat: create projects for KMS resources (#1032)
Co-authored-by: Grant Sorbo <[email protected]>
1 parent ed04795 commit f16e805

File tree

34 files changed

+258
-113
lines changed

34 files changed

+258
-113
lines changed

1-org/envs/shared/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
| log\_export\_storage\_location | The location of the storage bucket used to export logs. | `string` | `"US"` | no |
2222
| log\_export\_storage\_retention\_policy | Configuration of the bucket's data retention policy for how long objects in the bucket should be retained. | <pre>object({<br> is_locked = bool<br> retention_period_days = number<br> })</pre> | `null` | no |
2323
| log\_export\_storage\_versioning | (Optional) Toggles bucket versioning, ability to retain a non-current object version when the live object version gets replaced or deleted. | `bool` | `false` | no |
24-
| project\_budget | Budget configuration for projects.<br> budget\_amount: The amount to use as the budget.<br> alert\_spent\_percents: A list of percentages of the budget to alert on when threshold is exceeded.<br> alert\_pubsub\_topic: The name of the Cloud Pub/Sub topic where budget related messages will be published, in the form of `projects/{project_id}/topics/{topic_id}`.<br> alert\_spend\_basis: The type of basis used to determine if spend has passed the threshold. Possible choices are `CURRENT_SPEND` or `FORECASTED_SPEND` (default). | <pre>object({<br> dns_hub_budget_amount = optional(number, 1000)<br> dns_hub_alert_spent_percents = optional(list(number), [1.2])<br> dns_hub_alert_pubsub_topic = optional(string, null)<br> dns_hub_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")<br> base_net_hub_budget_amount = optional(number, 1000)<br> base_net_hub_alert_spent_percents = optional(list(number), [1.2])<br> base_net_hub_alert_pubsub_topic = optional(string, null)<br> base_net_hub_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")<br> base_network_budget_amount = optional(number, 1000)<br> base_network_alert_spent_percents = optional(list(number), [1.2])<br> base_network_alert_pubsub_topic = optional(string, null)<br> base_network_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")<br> restricted_net_hub_budget_amount = optional(number, 1000)<br> restricted_net_hub_alert_spent_percents = optional(list(number), [1.2])<br> restricted_net_hub_alert_pubsub_topic = optional(string, null)<br> restricted_net_hub_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")<br> restricted_network_budget_amount = optional(number, 1000)<br> restricted_network_alert_spent_percents = optional(list(number), [1.2])<br> restricted_network_alert_pubsub_topic = optional(string, null)<br> restricted_network_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")<br> interconnect_budget_amount = optional(number, 1000)<br> interconnect_alert_spent_percents = optional(list(number), [1.2])<br> interconnect_alert_pubsub_topic = optional(string, null)<br> interconnect_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")<br> org_secrets_budget_amount = optional(number, 1000)<br> org_secrets_alert_spent_percents = optional(list(number), [1.2])<br> org_secrets_alert_pubsub_topic = optional(string, null)<br> org_secrets_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")<br> org_billing_logs_budget_amount = optional(number, 1000)<br> org_billing_logs_alert_spent_percents = optional(list(number), [1.2])<br> org_billing_logs_alert_pubsub_topic = optional(string, null)<br> org_billing_logs_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")<br> org_audit_logs_budget_amount = optional(number, 1000)<br> org_audit_logs_alert_spent_percents = optional(list(number), [1.2])<br> org_audit_logs_alert_pubsub_topic = optional(string, null)<br> org_audit_logs_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")<br> scc_notifications_budget_amount = optional(number, 1000)<br> scc_notifications_alert_spent_percents = optional(list(number), [1.2])<br> scc_notifications_alert_pubsub_topic = optional(string, null)<br> scc_notifications_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")<br> })</pre> | `{}` | no |
24+
| project\_budget | Budget configuration for projects.<br> budget\_amount: The amount to use as the budget.<br> alert\_spent\_percents: A list of percentages of the budget to alert on when threshold is exceeded.<br> alert\_pubsub\_topic: The name of the Cloud Pub/Sub topic where budget related messages will be published, in the form of `projects/{project_id}/topics/{topic_id}`.<br> alert\_spend\_basis: The type of basis used to determine if spend has passed the threshold. Possible choices are `CURRENT_SPEND` or `FORECASTED_SPEND` (default). | <pre>object({<br> dns_hub_budget_amount = optional(number, 1000)<br> dns_hub_alert_spent_percents = optional(list(number), [1.2])<br> dns_hub_alert_pubsub_topic = optional(string, null)<br> dns_hub_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")<br> base_net_hub_budget_amount = optional(number, 1000)<br> base_net_hub_alert_spent_percents = optional(list(number), [1.2])<br> base_net_hub_alert_pubsub_topic = optional(string, null)<br> base_net_hub_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")<br> base_network_budget_amount = optional(number, 1000)<br> base_network_alert_spent_percents = optional(list(number), [1.2])<br> base_network_alert_pubsub_topic = optional(string, null)<br> base_network_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")<br> restricted_net_hub_budget_amount = optional(number, 1000)<br> restricted_net_hub_alert_spent_percents = optional(list(number), [1.2])<br> restricted_net_hub_alert_pubsub_topic = optional(string, null)<br> restricted_net_hub_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")<br> restricted_network_budget_amount = optional(number, 1000)<br> restricted_network_alert_spent_percents = optional(list(number), [1.2])<br> restricted_network_alert_pubsub_topic = optional(string, null)<br> restricted_network_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")<br> interconnect_budget_amount = optional(number, 1000)<br> interconnect_alert_spent_percents = optional(list(number), [1.2])<br> interconnect_alert_pubsub_topic = optional(string, null)<br> interconnect_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")<br> org_secrets_budget_amount = optional(number, 1000)<br> org_secrets_alert_spent_percents = optional(list(number), [1.2])<br> org_secrets_alert_pubsub_topic = optional(string, null)<br> org_secrets_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")<br> org_billing_logs_budget_amount = optional(number, 1000)<br> org_billing_logs_alert_spent_percents = optional(list(number), [1.2])<br> org_billing_logs_alert_pubsub_topic = optional(string, null)<br> org_billing_logs_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")<br> org_audit_logs_budget_amount = optional(number, 1000)<br> org_audit_logs_alert_spent_percents = optional(list(number), [1.2])<br> org_audit_logs_alert_pubsub_topic = optional(string, null)<br> org_audit_logs_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")<br> org_kms_budget_amount = optional(number, 1000)<br> org_kms_alert_spent_percents = optional(list(number), [1.2])<br> org_kms_alert_pubsub_topic = optional(string, null)<br> org_kms_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")<br> scc_notifications_budget_amount = optional(number, 1000)<br> scc_notifications_alert_spent_percents = optional(list(number), [1.2])<br> scc_notifications_alert_pubsub_topic = optional(string, null)<br> scc_notifications_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")<br> })</pre> | `{}` | no |
2525
| remote\_state\_bucket | Backend bucket to load Terraform Remote State Data from previous steps. | `string` | n/a | yes |
2626
| scc\_notification\_filter | Filter used to create the Security Command Center Notification, you can see more details on how to create filters in https://cloud.google.com/security-command-center/docs/how-to-api-filter-notifications#create-filter | `string` | `"state = \"ACTIVE\""` | no |
2727
| scc\_notification\_name | Name of the Security Command Center Notification. It must be unique in the organization. Run `gcloud scc notifications describe <scc_notification_name> --organization=org_id` to check if it already exists. | `string` | n/a | yes |
@@ -49,6 +49,7 @@
4949
| org\_audit\_logs\_project\_id | The org audit logs project ID. |
5050
| org\_billing\_logs\_project\_id | The org billing logs project ID |
5151
| org\_id | The organization id |
52+
| org\_kms\_project\_id | The org Cloud Key Management Service (KMS) project ID |
5253
| org\_secrets\_project\_id | The org secrets project ID |
5354
| parent\_resource\_id | The parent resource id |
5455
| parent\_resource\_type | The parent resource type |

1-org/envs/shared/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ output "org_secrets_project_id" {
5959
description = "The org secrets project ID"
6060
}
6161

62+
output "org_kms_project_id" {
63+
value = module.org_kms.project_id
64+
description = "The org Cloud Key Management Service (KMS) project ID"
65+
}
66+
6267
output "interconnect_project_id" {
6368
value = module.interconnect.project_id
6469
description = "The Dedicated Interconnect project ID"

1-org/envs/shared/projects.tf

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,39 @@ module "org_billing_logs" {
8888
budget_alert_spend_basis = var.project_budget.org_billing_logs_budget_alert_spend_basis
8989
}
9090

91+
/******************************************
92+
Project for Org-wide KMS
93+
*****************************************/
94+
95+
module "org_kms" {
96+
source = "terraform-google-modules/project-factory/google"
97+
version = "~> 14.0"
98+
99+
random_project_id = true
100+
random_project_id_length = 4
101+
default_service_account = "deprivilege"
102+
name = "${local.project_prefix}-c-kms"
103+
org_id = local.org_id
104+
billing_account = local.billing_account
105+
folder_id = google_folder.common.id
106+
activate_apis = ["logging.googleapis.com", "cloudkms.googleapis.com", "billingbudgets.googleapis.com"]
107+
108+
labels = {
109+
environment = "production"
110+
application_name = "org-kms"
111+
billing_code = "1234"
112+
primary_contact = "example1"
113+
secondary_contact = "example2"
114+
business_code = "abcd"
115+
env_code = "p"
116+
}
117+
118+
budget_alert_pubsub_topic = var.project_budget.org_kms_alert_pubsub_topic
119+
budget_alert_spent_percents = var.project_budget.org_kms_alert_spent_percents
120+
budget_amount = var.project_budget.org_kms_budget_amount
121+
budget_alert_spend_basis = var.project_budget.org_kms_budget_alert_spend_basis
122+
}
123+
91124
/******************************************
92125
Project for Org-wide Secrets
93126
*****************************************/

1-org/envs/shared/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ variable "project_budget" {
142142
org_audit_logs_alert_spent_percents = optional(list(number), [1.2])
143143
org_audit_logs_alert_pubsub_topic = optional(string, null)
144144
org_audit_logs_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
145+
org_kms_budget_amount = optional(number, 1000)
146+
org_kms_alert_spent_percents = optional(list(number), [1.2])
147+
org_kms_alert_pubsub_topic = optional(string, null)
148+
org_kms_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
145149
scc_notifications_budget_amount = optional(number, 1000)
146150
scc_notifications_alert_spent_percents = optional(list(number), [1.2])
147151
scc_notifications_alert_pubsub_topic = optional(string, null)

2-environments/envs/development/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
| Name | Description |
1313
|------|-------------|
1414
| env\_folder | Environment folder created under parent. |
15+
| env\_kms\_project\_id | Project for environment Cloud Key Management Service (KMS). |
1516
| env\_secrets\_project\_id | Project for environment related secrets. |
1617
| monitoring\_project\_id | Project for monitoring infra. |
1718

2-environments/envs/development/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,8 @@ output "env_secrets_project_id" {
2828
description = "Project for environment related secrets."
2929
value = module.env.env_secrets_project_id
3030
}
31+
32+
output "env_kms_project_id" {
33+
description = "Project for environment Cloud Key Management Service (KMS)."
34+
value = module.env.env_kms_project_id
35+
}

2-environments/envs/non-production/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
| Name | Description |
1313
|------|-------------|
1414
| env\_folder | Environment folder created under parent. |
15+
| env\_kms\_project\_id | Project for environment Cloud Key Management Service (KMS). |
1516
| env\_secrets\_project\_id | Project for environment related secrets. |
1617
| monitoring\_project\_id | Project for monitoring infra. |
1718

2-environments/envs/non-production/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,8 @@ output "env_secrets_project_id" {
2828
description = "Project for environment related secrets."
2929
value = module.env.env_secrets_project_id
3030
}
31+
32+
output "env_kms_project_id" {
33+
description = "Project for environment Cloud Key Management Service (KMS)."
34+
value = module.env.env_kms_project_id
35+
}

2-environments/envs/production/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
| assured\_workload\_id | Assured Workload ID. |
1515
| assured\_workload\_resources | Resources associated with the Assured Workload. |
1616
| env\_folder | Environment folder created under parent. |
17+
| env\_kms\_project\_id | Project for environment Cloud Key Management Service (KMS). |
1718
| env\_secrets\_project\_id | Project for environment related secrets. |
1819
| monitoring\_project\_id | Project for monitoring infra. |
1920

2-environments/envs/production/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ output "env_secrets_project_id" {
2929
value = module.env.env_secrets_project_id
3030
}
3131

32+
output "env_kms_project_id" {
33+
description = "Project for environment Cloud Key Management Service (KMS)."
34+
value = module.env.env_kms_project_id
35+
}
36+
3237
output "assured_workload_id" {
3338
description = "Assured Workload ID."
3439
value = module.env.assured_workload_id

0 commit comments

Comments
 (0)