Skip to content

Commit

Permalink
feat: add gcp consumption labels
Browse files Browse the repository at this point in the history
  • Loading branch information
assafgi committed Sep 30, 2024
1 parent 81b2e61 commit f8b9c9e
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 16 deletions.
9 changes: 9 additions & 0 deletions cloud_functions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 != ""
Expand Down Expand Up @@ -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]
}

Expand Down Expand Up @@ -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]
}

Expand Down
6 changes: 6 additions & 0 deletions health_check.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
Expand Down Expand Up @@ -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]
}
Expand Down
8 changes: 5 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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]
}
Expand All @@ -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]
}
Expand Down
3 changes: 3 additions & 0 deletions modules/clients/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
Expand Down
19 changes: 17 additions & 2 deletions modules/network/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}

Expand Down Expand Up @@ -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" {
Expand All @@ -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" {
Expand Down Expand Up @@ -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]
}

Expand Down Expand Up @@ -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]
}

Expand Down
5 changes: 4 additions & 1 deletion modules/protocol_gateways/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 0 additions & 1 deletion modules/shared_vpcs/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ resource "google_compute_firewall" "sg_private" {
protocol = "all"
}
source_tags = ["all"]

lifecycle {
ignore_changes = [network]
}
Expand Down
1 change: 0 additions & 1 deletion modules/worker_pool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand Down
11 changes: 9 additions & 2 deletions secret_manager.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<placeholder-for-weka-admin-password>"

lifecycle {
ignore_changes = [secret_data]
}
Expand All @@ -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]
}

Expand All @@ -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]
}

Expand All @@ -67,14 +72,16 @@ resource "google_secret_manager_secret" "secret_token" {
}
}
}
labels = {
goog-partner-solution = "isol_plb32_0014m00001h34hnqai_by7vmugtismizv6y46toim6jigajtrwh"
}
depends_on = [google_project_service.secret_manager]
}

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]
}
Expand Down
2 changes: 0 additions & 2 deletions state_object.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand 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
}
Expand Down
23 changes: 19 additions & 4 deletions workflows.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" {
Expand Down Expand Up @@ -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" {
Expand All @@ -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]
}

Expand Down

0 comments on commit f8b9c9e

Please sign in to comment.