1terraform { 2 required_providers { 3 google = { 4 source = "hashicorp/google" 5 } 6 } 7} 8resource "google_project_service" "iam" { 9 service = "iam.googleapis.com" 10 project = var.inputs.project_id 11 count = var.inputs.should_enable_apis_on_apply ? 1 : 0 12 disable_on_destroy = var.inputs.should_disable_apis_on_destroy 13} 14resource "random_id" "id" { 15 byte_length = 3 16} 17locals { 18 service_account_id = lower("service-account-id-${random_id.id.hex}") 19} 20resource "google_service_account" "service_account" { 21 account_id = local.service_account_id 22 display_name = "Service Account" 23 depends_on = [google_project_service.iam] 24} 25