Skip to content

Commit

Permalink
feat: add custom metrics writer role to autogen templates
Browse files Browse the repository at this point in the history
Signed-off-by: samuelarogbonlo <sbayo971@gmail.com>
  • Loading branch information
samuelarogbonlo committed Jan 16, 2025
1 parent 7916c38 commit df4ca10
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion autogen/main/sa.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ resource "google_project_iam_member" "cluster_service_account_node_service_accou
resource "google_project_iam_member" "cluster_service_account_metric_writer" {
count = var.create_service_account ? 1 : 0
project = google_service_account.cluster_service_account[0].project
role = "roles/monitoring.metricWriter"
role = var.monitoring_metric_writer_role
member = google_service_account.cluster_service_account[0].member
}

Expand Down
10 changes: 10 additions & 0 deletions autogen/main/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -1032,3 +1032,13 @@ variable "logging_variant" {
default = null
}
{% endif %}

variable "monitoring_metric_writer_role" {
description = "The monitoring metrics writer role to assign to the GKE node service account"
type = string
default = "roles/monitoring.metricWriter"
validation {
condition = can(regex("^(roles/[a-zA-Z0-9_.]+|projects/[a-zA-Z0-9-]+/roles/[a-zA-Z0-9_.]+)$", var.monitoring_metric_writer_role))
error_message = "The monitoring_metric_writer_role must be either a predefined role (roles/*) or a custom role (projects/*/roles/*)."
}
}

0 comments on commit df4ca10

Please sign in to comment.