From ff50d7d761dc7c34c620cec709d20b44759dd4e7 Mon Sep 17 00:00:00 2001 From: SWETA_RAJ Date: Thu, 5 Dec 2024 13:42:15 +0530 Subject: [PATCH] feat: added new variable support : create_ignore_already_exists_bool --- README.md | 1 + main.tf | 11 ++++++----- variables.tf | 6 ++++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b1944a1..f2e60f0 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ Functional examples are included in the | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | billing\_account\_id | If assigning billing role, specificy a billing account (default is to assign at the organizational level). | `string` | `""` | no | +| create\_ignore\_already\_exists | Whether to ignore errors when creating resources that already exist | `bool` | `false` | no | | description | Default description of the created service accounts (defaults to no description) | `string` | `""` | no | | descriptions | List of descriptions for the created service accounts (elements default to the value of `description`) | `list(string)` | `[]` | no | | display\_name | Display names of the created service accounts (defaults to 'Terraform-managed service account') | `string` | `"Terraform-managed service account"` | no | diff --git a/main.tf b/main.tf index 61376fd..8f965d5 100644 --- a/main.tf +++ b/main.tf @@ -35,11 +35,12 @@ locals { # create service accounts resource "google_service_account" "service_accounts" { - for_each = local.names - account_id = "${local.prefix}${lower(each.value)}" - display_name = var.display_name - description = index(var.names, each.value) >= length(var.descriptions) ? var.description : element(var.descriptions, index(var.names, each.value)) - project = var.project_id + for_each = local.names + account_id = "${local.prefix}${lower(each.value)}" + display_name = var.display_name + description = index(var.names, each.value) >= length(var.descriptions) ? var.description : element(var.descriptions, index(var.names, each.value)) + project = var.project_id + create_ignore_already_exists = var.create_ignore_already_exists } # common roles diff --git a/variables.tf b/variables.tf index 484d229..4ff9248 100644 --- a/variables.tf +++ b/variables.tf @@ -67,6 +67,12 @@ variable "generate_keys" { default = false } +variable "create_ignore_already_exists" { + type = bool + description = "Whether to ignore errors when creating resources that already exist" + default = false +} + variable "display_name" { type = string description = "Display names of the created service accounts (defaults to 'Terraform-managed service account')"