Skip to content

Commit

Permalink
feat: added new variable support : create_ignore_already_exists_bool
Browse files Browse the repository at this point in the history
  • Loading branch information
swetaraj-19 committed Dec 5, 2024
1 parent 5ed6967 commit ff50d7d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
11 changes: 6 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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')"
Expand Down

0 comments on commit ff50d7d

Please sign in to comment.