From f8b9c9e1249ff812da0120c85be1f16308cab209 Mon Sep 17 00:00:00 2001 From: Assaf Giladi Date: Wed, 11 Sep 2024 22:34:29 +0300 Subject: [PATCH] feat: add gcp consumption labels --- cloud_functions.tf | 9 +++++++++ health_check.tf | 6 ++++++ main.tf | 8 +++++--- modules/clients/main.tf | 3 +++ modules/network/main.tf | 19 +++++++++++++++++-- modules/protocol_gateways/main.tf | 5 ++++- modules/shared_vpcs/main.tf | 1 - modules/worker_pool/main.tf | 1 - secret_manager.tf | 11 +++++++++-- state_object.tf | 2 -- workflows.tf | 23 +++++++++++++++++++---- 11 files changed, 72 insertions(+), 16 deletions(-) diff --git a/cloud_functions.tf b/cloud_functions.tf index d2ecc352..e8735c30 100644 --- a/cloud_functions.tf +++ b/cloud_functions.tf @@ -130,6 +130,9 @@ resource "google_cloudfunctions2_function" "cloud_internal_function" { S3_PROTOCOL_GATEWAY_FE_CORES_NUM = var.s3_protocol_gateway_fe_cores_num } } + labels = { + goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh" + } lifecycle { precondition { condition = var.install_weka_url != "" || var.weka_version != "" @@ -175,6 +178,9 @@ resource "google_cloudfunctions2_function" "scale_down_function" { all_traffic_on_latest_revision = true service_account_email = local.sa_email } + labels = { + goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh" + } depends_on = [module.network, module.worker_pool, module.shared_vpc_peering, google_project_service.project_function_api, google_project_service.run_api, google_project_service.artifactregistry_api] } @@ -227,6 +233,9 @@ resource "google_cloudfunctions2_function" "status_function" { DEPLOYMENT_PASSWORD_ID : google_secret_manager_secret.weka_deployment_password.id } } + labels = { + goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh" + } depends_on = [module.network, module.worker_pool, module.shared_vpc_peering, google_project_service.project_function_api, google_project_service.run_api, google_project_service.artifactregistry_api] } diff --git a/health_check.tf b/health_check.tf index a5772909..35b499ab 100644 --- a/health_check.tf +++ b/health_check.tf @@ -37,6 +37,9 @@ resource "google_compute_forwarding_rule" "google_compute_forwarding_rule" { allow_global_access = var.lb_allow_global_access network = data.google_compute_network.this[0].self_link subnetwork = data.google_compute_subnetwork.this[0].self_link + labels = { + goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh" + } lifecycle { ignore_changes = [network, subnetwork] } @@ -95,6 +98,9 @@ resource "google_compute_forwarding_rule" "ui_forwarding_rule" { allow_global_access = var.lb_allow_global_access network = data.google_compute_network.this[0].self_link subnetwork = data.google_compute_subnetwork.this[0].self_link + labels = { + goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh" + } lifecycle { ignore_changes = [network, subnetwork] } diff --git a/main.tf b/main.tf index f54cfefb..307dac18 100644 --- a/main.tf +++ b/main.tf @@ -4,6 +4,9 @@ resource "google_storage_bucket" "weka_deployment" { name = "${var.prefix}-${var.cluster_name}-${var.project_id}" location = var.region uniform_bucket_level_access = true + labels = { + goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh" + } lifecycle { precondition { condition = length(var.prefix) + length(var.cluster_name) + length(var.project_id) <= 63 @@ -26,7 +29,8 @@ resource "google_compute_instance_template" "this" { tags = ["${var.prefix}-${var.cluster_name}-backends", "allow-health-check", "backends", "all-apis"] labels = { - weka_cluster_name = var.cluster_name + weka_cluster_name = var.cluster_name + goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh" } service_account { email = local.sa_email @@ -96,7 +100,6 @@ resource "google_compute_instance_group" "this" { zone = var.zone network = data.google_compute_network.this[0].self_link depends_on = [google_compute_region_health_check.health_check, module.network, module.shared_vpc_peering] - lifecycle { ignore_changes = [network] } @@ -108,7 +111,6 @@ resource "google_compute_instance_group" "nfs" { zone = var.zone network = data.google_compute_network.this[0].self_link depends_on = [google_compute_region_health_check.health_check, module.network, module.shared_vpc_peering] - lifecycle { ignore_changes = [network] } diff --git a/modules/clients/main.tf b/modules/clients/main.tf index 29b3f682..970f18b8 100644 --- a/modules/clients/main.tf +++ b/modules/clients/main.tf @@ -71,6 +71,9 @@ resource "google_compute_instance" "this" { scheduling { on_host_maintenance = try(var.instance_config_overrides[var.machine_type].host_maintenance, "MIGRATE") } + labels = { + goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh" + } lifecycle { ignore_changes = [network_interface, metadata_startup_script] } diff --git a/modules/network/main.tf b/modules/network/main.tf index cc4eac96..92edcb72 100644 --- a/modules/network/main.tf +++ b/modules/network/main.tf @@ -368,6 +368,9 @@ resource "google_dns_managed_zone" "private_zone" { } } } + labels = { + goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh" + } depends_on = [google_project_service.project_dns] } @@ -430,7 +433,10 @@ resource "google_compute_global_forwarding_rule" "apis_forwarding_rule" { network = google_compute_network.vpc_network[0].self_link ip_address = google_compute_global_address.apis_ip[0].id load_balancing_scheme = "" - depends_on = [google_compute_global_address.apis_ip] + labels = { + goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh" + } + depends_on = [google_compute_global_address.apis_ip] } resource "google_compute_global_forwarding_rule" "vpcsc_forwarding_rule" { @@ -441,7 +447,10 @@ resource "google_compute_global_forwarding_rule" "vpcsc_forwarding_rule" { network = google_compute_network.vpc_network[0].self_link ip_address = google_compute_global_address.vpcsc_ip[0].id load_balancing_scheme = "" - depends_on = [google_compute_global_address.vpcsc_ip] + labels = { + goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh" + } + depends_on = [google_compute_global_address.vpcsc_ip] } resource "google_compute_firewall" "allow_endpoint_sg" { @@ -474,6 +483,9 @@ resource "google_dns_managed_zone" "cloud_run_zone" { } } } + labels = { + goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh" + } depends_on = [google_project_service.project_dns, google_compute_network.vpc_network] } @@ -504,6 +516,9 @@ resource "google_dns_managed_zone" "googleapis_zone" { } } } + labels = { + goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh" + } depends_on = [google_project_service.project_dns, google_compute_network.vpc_network] } diff --git a/modules/protocol_gateways/main.tf b/modules/protocol_gateways/main.tf index 994b1c16..deee2d27 100644 --- a/modules/protocol_gateways/main.tf +++ b/modules/protocol_gateways/main.tf @@ -59,6 +59,7 @@ resource "google_compute_instance_template" "this" { labels = { weka_protocol_gateway = var.gateways_name + goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh" } metadata = { @@ -148,7 +149,9 @@ resource "google_compute_instance_from_template" "this" { source_instance_template = google_compute_instance_template.this.self_link can_ip_forward = false depends_on = [google_compute_instance_template.this] - + labels = { + goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh" + } lifecycle { ignore_changes = all } diff --git a/modules/shared_vpcs/main.tf b/modules/shared_vpcs/main.tf index 6604b09d..73c9b78c 100644 --- a/modules/shared_vpcs/main.tf +++ b/modules/shared_vpcs/main.tf @@ -61,7 +61,6 @@ resource "google_compute_firewall" "sg_private" { protocol = "all" } source_tags = ["all"] - lifecycle { ignore_changes = [network] } diff --git a/modules/worker_pool/main.tf b/modules/worker_pool/main.tf index 42ff9ce9..c68c9c1f 100644 --- a/modules/worker_pool/main.tf +++ b/modules/worker_pool/main.tf @@ -76,7 +76,6 @@ resource "google_compute_network_peering_routes_config" "service_networking_peer export_custom_routes = true import_custom_routes = true - depends_on = [ google_service_networking_connection.worker_pool_connection, google_project_service_identity.servicenetworking_agent, google_project_iam_member.servicenetworking_agent, google_project_iam_member.service_networking_network_proj ] diff --git a/secret_manager.tf b/secret_manager.tf index 005096fd..7b943122 100644 --- a/secret_manager.tf +++ b/secret_manager.tf @@ -19,7 +19,6 @@ resource "google_secret_manager_secret" "secret_weka_password" { resource "google_secret_manager_secret_version" "password_secret_key" { secret = google_secret_manager_secret.secret_weka_password.id secret_data = "" - lifecycle { ignore_changes = [secret_data] } @@ -35,6 +34,9 @@ resource "google_secret_manager_secret" "weka_deployment_password" { } } } + labels = { + goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh" + } depends_on = [google_project_service.secret_manager] } @@ -48,6 +50,9 @@ resource "google_secret_manager_secret" "secret_weka_username" { } } } + labels = { + goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh" + } depends_on = [google_project_service.secret_manager] } @@ -67,6 +72,9 @@ resource "google_secret_manager_secret" "secret_token" { } } } + labels = { + goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh" + } depends_on = [google_project_service.secret_manager] } @@ -74,7 +82,6 @@ resource "google_secret_manager_secret_version" "token_secret_key" { count = var.get_weka_io_token != "" ? 1 : 0 secret = google_secret_manager_secret.secret_token[0].id secret_data = var.get_weka_io_token - lifecycle { ignore_changes = [secret_data] } diff --git a/state_object.tf b/state_object.tf index f8a36129..aafcc6a6 100644 --- a/state_object.tf +++ b/state_object.tf @@ -8,7 +8,6 @@ resource "google_storage_bucket_object" "state" { bucket = local.state_bucket content_type = "application/json" content = "{\"initial_size\":${var.cluster_size}, \"desired_size\":${var.cluster_size}, \"instances\":[], \"clusterized\":false, \"clusterization_target\":${var.cluster_size}}" - lifecycle { ignore_changes = all } @@ -28,7 +27,6 @@ resource "google_storage_bucket_object" "nfs_state" { clusterization_target = var.nfs_protocol_gateways_number nfs_instances_migrated = false }) - lifecycle { ignore_changes = all } diff --git a/workflows.tf b/workflows.tf index d7720749..18aa6da3 100644 --- a/workflows.tf +++ b/workflows.tf @@ -60,12 +60,17 @@ resource "google_workflows_workflow" "scale_down" { - returnOutput: return: $${TransientResult} EOF - + labels = { + goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh" + } depends_on = [google_project_service.workflows, google_cloudfunctions2_function.scale_down_function, google_cloudfunctions2_function.cloud_internal_function] } resource "google_pubsub_topic" "scale_down_trigger_topic" { name = "${var.prefix}-${var.cluster_name}-scale-down" + labels = { + goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh" + } } # needed for google_eventarc_trigger @@ -93,7 +98,10 @@ resource "google_eventarc_trigger" "scale_down_trigger" { } service_account = local.sa_email - depends_on = [google_workflows_workflow.scale_down, google_pubsub_topic.scale_down_trigger_topic] + labels = { + goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh" + } + depends_on = [google_workflows_workflow.scale_down, google_pubsub_topic.scale_down_trigger_topic] } resource "google_cloud_scheduler_job" "scale_down_job" { @@ -128,12 +136,17 @@ resource "google_workflows_workflow" "scale_up" { - returnOutput: return: $${ScaleUpResult} EOF - + labels = { + goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh" + } depends_on = [google_project_service.workflows, google_cloudfunctions2_function.cloud_internal_function] } resource "google_pubsub_topic" "scale_up_trigger_topic" { name = "${var.prefix}-${var.cluster_name}-scale-up" + labels = { + goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh" + } } resource "google_eventarc_trigger" "scale_up_trigger" { @@ -154,7 +167,9 @@ resource "google_eventarc_trigger" "scale_up_trigger" { } service_account = local.sa_email - + labels = { + goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh" + } depends_on = [google_workflows_workflow.scale_up, google_pubsub_topic.scale_up_trigger_topic] }