Skip to content
Closed
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
11 changes: 11 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,15 @@ resource "google_organization_iam_member" "organization_viewer" {
resource "google_service_account_key" "keys" {
for_each = var.generate_keys ? local.names : toset([])
service_account_id = google_service_account.service_accounts[each.value].email
keepers = {
rotation_time = var.key_rotation_days == null ? null : time_rotating.key_rotation["key_rotation_days"].rotation_rfc3339
}

}

resource "time_rotating" "key_rotation" {
for_each = var.key_rotation_days == null ? {} : {
"key_rotation_days" = var.key_rotation_days
}
rotation_days = var.key_rotation_days
}
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,9 @@ variable "descriptions" {
description = "List of descriptions for the created service accounts (elements default to the value of `description`)"
default = []
}

variable "key_rotation_days" {
type = number
description = "Number of days after which the service account key is rotated"
default = null
}
4 changes: 4 additions & 0 deletions versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ terraform {
source = "hashicorp/google"
version = ">= 3.53, < 7"
}
time = {
source = "hashicorp/time"
version = "~> 0.12"
}
}

provider_meta "google" {
Expand Down