Skip to content

Commit a719426

Browse files
authored
chore(resourcehierarchy): disambiguate prj-c-logging and prj-c-billing-logs (#1197)
1 parent 7211d87 commit a719426

File tree

8 files changed

+31
-27
lines changed

8 files changed

+31
-27
lines changed

1-org/envs/shared/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
| log\_export\_storage\_location | The location of the storage bucket used to export logs. | `string` | `null` | no |
1919
| 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 |
2020
| 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 |
21-
| 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 |
21+
| 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_export_budget_amount = optional(number, 1000)<br> org_billing_export_alert_spent_percents = optional(list(number), [1.2])<br> org_billing_export_alert_pubsub_topic = optional(string, null)<br> org_billing_export_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 |
2222
| remote\_state\_bucket | Backend bucket to load Terraform Remote State Data from previous steps. | `string` | n/a | yes |
2323
| 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 |
2424
| 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 |
@@ -45,7 +45,7 @@
4545
| logs\_export\_storage\_bucket\_name | The storage bucket for destination of log exports |
4646
| network\_folder\_name | The network folder name. |
4747
| org\_audit\_logs\_project\_id | The org audit logs project ID. |
48-
| org\_billing\_logs\_project\_id | The org billing logs project ID |
48+
| org\_billing\_export\_project\_id | The org billing export project ID |
4949
| org\_id | The organization id |
5050
| org\_kms\_project\_id | The org Cloud Key Management Service (KMS) project ID |
5151
| org\_secrets\_project\_id | The org secrets project ID |

1-org/envs/shared/iam.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ resource "google_project_iam_member" "audit_log_bq_data_viewer" {
8787
*****************************************/
8888

8989
resource "google_project_iam_member" "billing_bq_user" {
90-
project = module.org_billing_logs.project_id
90+
project = module.org_billing_export.project_id
9191
role = "roles/bigquery.user"
9292
member = "group:${local.required_groups["billing_data_users"]}"
9393
}
9494

9595
resource "google_project_iam_member" "billing_bq_viewer" {
96-
project = module.org_billing_logs.project_id
96+
project = module.org_billing_export.project_id
9797
role = "roles/bigquery.dataViewer"
9898
member = "group:${local.required_groups["billing_data_users"]}"
9999
}

1-org/envs/shared/log_sinks.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ module "logs_export" {
9191

9292
resource "google_bigquery_dataset" "billing_dataset" {
9393
dataset_id = "billing_data"
94-
project = module.org_billing_logs.project_id
94+
project = module.org_billing_export.project_id
9595
friendly_name = "GCP Billing Data"
9696
location = coalesce(var.billing_export_dataset_location, local.default_region)
9797
}

1-org/envs/shared/outputs.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ output "org_audit_logs_project_id" {
4949
description = "The org audit logs project ID."
5050
}
5151

52-
output "org_billing_logs_project_id" {
53-
value = module.org_billing_logs.project_id
54-
description = "The org billing logs project ID"
52+
output "org_billing_export_project_id" {
53+
value = module.org_billing_export.project_id
54+
description = "The org billing export project ID"
5555
}
5656

5757
output "org_secrets_project_id" {

1-org/envs/shared/projects.tf

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ locals {
2929
}
3030

3131
/******************************************
32-
Projects for log sinks
32+
Project for log sinks
3333
*****************************************/
3434

3535
module "org_audit_logs" {
@@ -61,33 +61,37 @@ module "org_audit_logs" {
6161
budget_alert_spend_basis = var.project_budget.org_audit_logs_budget_alert_spend_basis
6262
}
6363

64-
module "org_billing_logs" {
64+
/******************************************
65+
Project for billing export
66+
*****************************************/
67+
68+
module "org_billing_export" {
6569
source = "terraform-google-modules/project-factory/google"
6670
version = "~> 15.0"
6771

6872
random_project_id = true
6973
random_project_id_length = 4
7074
default_service_account = "deprivilege"
71-
name = "${local.project_prefix}-c-billing-logs"
75+
name = "${local.project_prefix}-c-billing-export"
7276
org_id = local.org_id
7377
billing_account = local.billing_account
7478
folder_id = google_folder.common.id
7579
activate_apis = ["logging.googleapis.com", "bigquery.googleapis.com", "billingbudgets.googleapis.com"]
7680

7781
labels = {
7882
environment = "common"
79-
application_name = "org-billing-logs"
83+
application_name = "org-billing-export"
8084
billing_code = "1234"
8185
primary_contact = "example1"
8286
secondary_contact = "example2"
8387
business_code = "shared"
8488
env_code = "c"
8589
vpc = "none"
8690
}
87-
budget_alert_pubsub_topic = var.project_budget.org_billing_logs_alert_pubsub_topic
88-
budget_alert_spent_percents = var.project_budget.org_billing_logs_alert_spent_percents
89-
budget_amount = var.project_budget.org_billing_logs_budget_amount
90-
budget_alert_spend_basis = var.project_budget.org_billing_logs_budget_alert_spend_basis
91+
budget_alert_pubsub_topic = var.project_budget.org_billing_export_alert_pubsub_topic
92+
budget_alert_spent_percents = var.project_budget.org_billing_export_alert_spent_percents
93+
budget_amount = var.project_budget.org_billing_export_budget_amount
94+
budget_alert_spend_basis = var.project_budget.org_billing_export_budget_alert_spend_basis
9195
}
9296

9397
/******************************************

1-org/envs/shared/variables.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ variable "project_budget" {
125125
org_secrets_alert_spent_percents = optional(list(number), [1.2])
126126
org_secrets_alert_pubsub_topic = optional(string, null)
127127
org_secrets_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
128-
org_billing_logs_budget_amount = optional(number, 1000)
129-
org_billing_logs_alert_spent_percents = optional(list(number), [1.2])
130-
org_billing_logs_alert_pubsub_topic = optional(string, null)
131-
org_billing_logs_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
128+
org_billing_export_budget_amount = optional(number, 1000)
129+
org_billing_export_alert_spent_percents = optional(list(number), [1.2])
130+
org_billing_export_alert_pubsub_topic = optional(string, null)
131+
org_billing_export_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
132132
org_audit_logs_budget_amount = optional(number, 1000)
133133
org_audit_logs_alert_spent_percents = optional(list(number), [1.2])
134134
org_audit_logs_alert_pubsub_topic = optional(string, null)

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ This will create the following folder and project structure:
6464
example-organization
6565
└── fldr-common
6666
├── prj-c-logging
67-
├── prj-c-billing-logs
67+
├── prj-c-billing-export
6868
├── prj-c-scc
6969
├── prj-c-kms
7070
└── prj-c-secrets
@@ -83,9 +83,9 @@ example-organization
8383

8484
#### Logs
8585

86-
Among the four projects created under the common folder, two projects (`prj-c-logging`, `prj-c-billing-logs`) are used for logging.
87-
The first one is for organization-wide audit logs, and the second one is for billing logs.
88-
In both cases, the logs are collected into BigQuery datasets which you can then use for general querying, dashboarding, and reporting. Logs are also exported to Pub/Sub, a Cloud Storage bucket, and a log bucket.
86+
Under the common folder, a project `prj-c-logging` is used as the destination for organization wide sinks. This includes admin activity audit logs from all projects in your organization and the billing account.
87+
88+
Logs are collected into a logging bucket with a linked BigQuery dataset, which can be used for ad-hoc log investigations, querying, or reporting. Log sinks can also be configured to export to Pub/Sub for exporting to external systems or Cloud Storage for long-term storage.
8989

9090
**Notes**:
9191

@@ -248,7 +248,7 @@ After all steps above have been executed, your Google Cloud organization should
248248
example-organization
249249
└── fldr-common
250250
├── prj-c-logging
251-
├── prj-c-billing-logs
251+
├── prj-c-billing-export
252252
├── prj-c-scc
253253
├── prj-c-kms
254254
├── prj-c-secrets

test/integration/org/org_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func TestOrg(t *testing.T) {
214214
assert.Subset(listCategories, expectedCategories, "notification category subscriptions should be the same")
215215

216216
//logging
217-
billingLogsProjectID := org.GetStringOutput("org_billing_logs_project_id")
217+
billingLogsProjectID := org.GetStringOutput("org_billing_export_project_id")
218218
billingDatasetName := "billing_data"
219219
billingDatasetFullName := fmt.Sprintf("%s:%s", billingLogsProjectID, billingDatasetName)
220220
billingDataset := gcloud.Runf(t, "alpha bq datasets describe %s --project %s", billingDatasetName, billingLogsProjectID)
@@ -409,7 +409,7 @@ func TestOrg(t *testing.T) {
409409
},
410410
},
411411
{
412-
output: "org_billing_logs_project_id",
412+
output: "org_billing_export_project_id",
413413
apis: []string{
414414
"logging.googleapis.com",
415415
"bigquery.googleapis.com",

0 commit comments

Comments
 (0)