Skip to content

Commit badaaf3

Browse files
authored
feat: Add support for custom display_name and description #18 (#19)
* Resolves #18 Added support for display_name and description when creating the service acocunts. * Upped provider version in examples to latest version, since version 2.7.0 of google provider did not support description field.
1 parent cb47b8c commit badaaf3

File tree

6 files changed

+22
-3
lines changed

6 files changed

+22
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to
1111

1212
### Added
1313

14+
- Support for `display_name` and `description` [#18]
1415
- Use `for_each` instead of `count` [#15]
1516

1617
## [2.0.2] - 2019-10-09

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ Functional examples are included in the
4343
| Name | Description | Type | Default | Required |
4444
|------|-------------|:----:|:-----:|:-----:|
4545
| billing\_account\_id | If assigning billing role, specificy a billing account (default is to assign at the organizational level). | string | `""` | no |
46+
| description | Descriptions of the created service accounts (defaults to no description) | string | `""` | no |
47+
| display\_name | Display names of the created service accounts (defaults to 'Terraform-managed service account') | string | `"Terraform-managed service account"` | no |
4648
| generate\_keys | Generate keys for service accounts. | bool | `"false"` | no |
4749
| grant\_billing\_role | Grant billing user role. | bool | `"false"` | no |
4850
| grant\_xpn\_roles | Grant roles for shared VPC management. | bool | `"true"` | no |

examples/multiple_service_accounts/main.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
provider "google" {
18-
version = "~> 2.7.0"
18+
version = "~> 3.17.0"
1919
}
2020

2121
module "service_accounts" {
@@ -24,6 +24,8 @@ module "service_accounts" {
2424
prefix = ""
2525
names = ["test-first", "test-second"]
2626
generate_keys = true
27+
display_name = "Test Service Accounts"
28+
description = "Test Service Accounts description"
2729

2830
project_roles = [
2931
"${var.project_id}=>roles/viewer",

examples/single_service_account/main.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
provider "google" {
18-
version = "~> 2.7.0"
18+
version = "~> 3.17.0"
1919
}
2020

2121
module "service_accounts" {
@@ -24,5 +24,7 @@ module "service_accounts" {
2424
prefix = var.prefix
2525
names = ["single-account"]
2626
project_roles = ["${var.project_id}=>roles/viewer"]
27+
display_name = "Single Account"
28+
description = "Single Account Description"
2729
}
2830

main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ locals {
3737
resource "google_service_account" "service_accounts" {
3838
for_each = local.names
3939
account_id = "${local.prefix}${lower(each.value)}"
40-
display_name = "Terraform-managed service account"
40+
display_name = var.display_name
41+
description = var.description
4142
project = var.project_id
4243
}
4344

variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,14 @@ variable "generate_keys" {
6767
default = false
6868
}
6969

70+
variable "display_name" {
71+
type = string
72+
description = "Display names of the created service accounts (defaults to 'Terraform-managed service account')"
73+
default = "Terraform-managed service account"
74+
}
75+
76+
variable "description" {
77+
type = string
78+
description = "Descriptions of the created service accounts (defaults to no description)"
79+
default = ""
80+
}

0 commit comments

Comments
 (0)