Skip to content

Commit ef24bb9

Browse files
committed
add owner label to everything
1 parent d90ef46 commit ef24bb9

22 files changed

Lines changed: 110 additions & 10 deletions

File tree

functions/main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ variable "region" {}
1010
variable "secret_ids" {}
1111
variable "deploy_sa_email" {}
1212
variable "local_variables" {}
13+
variable "owner" {}
1314

1415
module "cloud_function_gen2" {
1516
source = "../modules/cloud-function-gen2"
@@ -40,6 +41,7 @@ module "cloud_function_gen2" {
4041
project = var.project
4142
secret_ids = var.secret_ids
4243
deploy_sa_email = var.deploy_sa_email
44+
owner = var.owner
4345
}
4446

4547
module "cronjob-gen2" {
@@ -58,6 +60,7 @@ module "cronjob-gen2" {
5860
target_project = var.project
5961
target_region = var.region
6062
deploy_sa_email = var.deploy_sa_email
63+
owner = var.owner
6164

6265
depends_on = [
6366
module.cloud_function_gen2

index.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module "infrastructure" {
55
region = var.region
66
project_id = var.project_id
77
deploy_sa_email = var.deploy_sa_email
8+
owner = var.owner
89
}
910

1011
module "functions" {
@@ -16,6 +17,7 @@ module "functions" {
1617
secret_ids = module.infrastructure.secret_ids
1718
deploy_sa_email = var.deploy_sa_email != null ? var.deploy_sa_email : module.infrastructure.deploy_sa_email
1819
local_variables = local.local_variables
20+
owner = var.owner
1921

2022
depends_on = [
2123
module.infrastructure
@@ -29,9 +31,11 @@ module "workflows" {
2931
region = var.region
3032
project_id = var.project_id
3133
deploy_sa_email = var.deploy_sa_email != null ? var.deploy_sa_email : module.infrastructure.deploy_sa_email
34+
owner = var.owner
3235

3336
depends_on = [
34-
module.infrastructure
37+
module.infrastructure,
38+
module.functions
3539
]
3640
}
3741

@@ -44,6 +48,7 @@ module "pubsubs" {
4448
bucket_location = var.bucket_location
4549
zone = var.zone
4650
deploy_sa_email = var.deploy_sa_email != null ? var.deploy_sa_email : module.infrastructure.deploy_sa_email
51+
owner = var.owner
4752

4853
depends_on = [
4954
module.infrastructure

infrastructure/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ resource "google_storage_bucket" "staging_bucket" {
33
location = "US"
44
force_destroy = true
55
public_access_prevention = "enforced"
6+
labels = {
7+
owner = var.owner
8+
terraformed = "true"
9+
}
610
}
711

812
resource "google_storage_bucket_iam_binding" "staging-bucket-iam" {
@@ -31,6 +35,10 @@ resource "google_storage_bucket" "tf-state" {
3135
versioning {
3236
enabled = true
3337
}
38+
labels = {
39+
owner = var.owner
40+
terraformed = "true"
41+
}
3442
}
3543

3644
resource "google_storage_bucket_iam_binding" "tfstate-bucket-iam" {

infrastructure/secrets.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ resource "google_secret_manager_secret" "secret" {
44
replication {
55
auto {}
66
}
7+
labels = {
8+
owner = var.owner
9+
terraformed = "true"
10+
}
711
}
812

913
# since some of the secrets will be shared across functions and workflows

infrastructure/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,8 @@ variable "deploy_sa_email" {
1919
description = "service account for deployment"
2020
default = null
2121
}
22+
23+
variable "owner" {
24+
type = string
25+
description = "The owner of the project, used for tagging resources and future ownership tracking"
26+
}

infrastructure/workload_identity.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ resource "google_service_account" "gha_cloud_functions_deployment" {
77
count = var.deploy_sa_email != null ? 0 : 1
88

99
account_id = "gha-cloud-functions-deployment"
10-
description = "For use by Terraform and GitHub Actions to deploy cloud-functions"
10+
description = "For use by Terraform and GitHub Actions to deploy cloud-functions, owned by ${var.owner}, managed by Terraform"
1111
display_name = "gha-cloud-functions-deployment"
1212
project = var.project
1313
}
@@ -17,7 +17,7 @@ resource "google_iam_workload_identity_pool" "gha_terraform_checker_pool" {
1717

1818
workload_identity_pool_id = "${local.gha_name}-pool"
1919
display_name = "GHA Terraform Checker Pool"
20-
description = "Identity pool for Terraform Plan GHA"
20+
description = "Identity pool for Terraform Plan GHA, owned by ${var.owner}, managed by Terraform"
2121
}
2222

2323
resource "google_iam_workload_identity_pool_provider" "gha_terraform_checker_provider" {
@@ -26,7 +26,7 @@ resource "google_iam_workload_identity_pool_provider" "gha_terraform_checker_pro
2626
workload_identity_pool_id = google_iam_workload_identity_pool.gha_terraform_checker_pool[0].workload_identity_pool_id
2727
workload_identity_pool_provider_id = "${local.gha_name}-provider"
2828
display_name = "GHA Terraform Checker Provider"
29-
description = "OIDC identity pool provider for Terraform Plan GHA"
29+
description = "OIDC identity pool provider for Terraform Plan GHA, owned by ${var.owner}, managed by Terraform"
3030

3131
attribute_mapping = {
3232
"google.subject" = "assertion.${local.attribute_scope}"

modules/cloud-function-gen2/main.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
resource "google_service_account" "function_sa" {
22
account_id = "cf-${var.name}"
33
display_name = "Cloud Function Service Account for ${var.name}"
4+
description = "Service account for ${var.name}, owned by ${var.owner}, managed by Terraform"
45
}
56

67

@@ -65,6 +66,10 @@ data "archive_file" "source" {
6566
resource "google_storage_bucket_object" "zip" {
6667
source = data.archive_file.source.output_path
6768
content_type = "application/zip"
69+
metadata = {
70+
owner = var.owner
71+
terraformed = "true"
72+
}
6873

6974
# Append to the MD5 checksum of the files's content
7075
# to force the zip to be updated as soon as a change occurs
@@ -76,6 +81,10 @@ resource "google_cloudfunctions2_function" "function" {
7681
name = var.name
7782
location = var.location
7883
description = var.description
84+
labels = {
85+
owner = var.owner
86+
terraformed = "true"
87+
}
7988

8089
build_config {
8190
runtime = var.runtime

modules/cloud-function-gen2/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,8 @@ variable "allow_unauthenticated" {
117117
nullable = false
118118
default = false
119119
}
120+
121+
variable "owner" {
122+
type = string
123+
description = "The owner of the project, used for tagging resources and future ownership tracking"
124+
}

modules/cloud-workflow/main.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
resource "google_service_account" "workflow_sa" {
22
account_id = "wf-${var.name}"
33
display_name = "Workflow Service Account for ${var.name}"
4+
description = "Service account for ${var.name}, owned by ${var.owner}, managed by Terraform"
45
}
56

67
resource "google_service_account_iam_member" "workflow_sa_actas_iam" {
@@ -20,6 +21,11 @@ resource "google_workflows_workflow" "workflow" {
2021
description = var.description
2122
service_account = google_service_account.workflow_sa.id
2223
source_contents = templatefile("${var.workflow_yaml_file}", {})
24+
labels = {
25+
owner = var.owner
26+
terraformed = "true"
27+
}
28+
2329
depends_on = [
2430
google_service_account_iam_member.workflow_sa_actas_iam,
2531
google_service_account_iam_member.deploy_sa_actas_iam

modules/cloud-workflow/variables.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,16 @@ variable "deploy_sa_email" {
4040
variable "project" {
4141
type = string
4242
}
43+
4344
variable "project_id" {
4445
type = string
4546
}
47+
4648
variable "region" {
4749
type = string
4850
}
51+
52+
variable "owner" {
53+
type = string
54+
description = "The owner of the project, used for tagging resources and future ownership tracking"
55+
}

0 commit comments

Comments
 (0)