Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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