From 5eb587cf908d93252245f1fd447deb3b466ed755 Mon Sep 17 00:00:00 2001 From: Bishop Bettini Date: Thu, 29 Dec 2022 11:51:27 -0500 Subject: [PATCH 1/6] feat: expand common tags To give more built-in means for categorizing resources. --- lib/terraform/tags.common.tf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/terraform/tags.common.tf b/lib/terraform/tags.common.tf index f8b4cb8..6eda0f8 100644 --- a/lib/terraform/tags.common.tf +++ b/lib/terraform/tags.common.tf @@ -10,7 +10,7 @@ # @seealso https://support.hashicorp.com/hc/en-us/articles/4406026108435 locals { common_tags = { - # Note: to avoid CreatedAt being overwritten each deploy, add a lifecycle + # Note: to avoid Created values being overwritten each deploy, add a lifecycle # Note: block to every resource, like so: # Note: lifecycle { ignore_changes = [ tags["CreatedAt"], tags["CreatedBy"] ] } CreatedAt = timestamp() @@ -20,5 +20,7 @@ locals { Project = var.project Component = var.component ImageTag = var.image_tag + Repository = var.repository + Product = var.product } } From 18b605dbf794e63d11eade0c0c2d615a14378825 Mon Sep 17 00:00:00 2001 From: Bishop Bettini Date: Thu, 29 Dec 2022 11:57:15 -0500 Subject: [PATCH 2/6] feat:add variables --- lib/terraform/variables.common.tf | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/terraform/variables.common.tf b/lib/terraform/variables.common.tf index 351e278..524b4a4 100644 --- a/lib/terraform/variables.common.tf +++ b/lib/terraform/variables.common.tf @@ -25,3 +25,17 @@ variable "user" { sensitive = false nullable = false } + +variable "repository" { + type = string + description = "The source code repository where the component code can be found" + sensitive = false + nullable = false +} + +variable "product" { + type = string + description = "The product supported by the component" + sensitive = false + nullable = false +} From 90be3b19c36995076cd4b4a06a07ab023450b469 Mon Sep 17 00:00:00 2001 From: Bishop Bettini Date: Thu, 29 Dec 2022 12:00:03 -0500 Subject: [PATCH 3/6] feat: set defaults for new variables --- lib/terraform/variables.common.tf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/terraform/variables.common.tf b/lib/terraform/variables.common.tf index 524b4a4..acc88a4 100644 --- a/lib/terraform/variables.common.tf +++ b/lib/terraform/variables.common.tf @@ -31,6 +31,7 @@ variable "repository" { description = "The source code repository where the component code can be found" sensitive = false nullable = false + default = "" } variable "product" { @@ -38,4 +39,5 @@ variable "product" { description = "The product supported by the component" sensitive = false nullable = false + default = "" } From 846564d7da8544566304f64fc7e7332bac959b8c Mon Sep 17 00:00:00 2001 From: Bishop Bettini Date: Thu, 29 Dec 2022 12:03:29 -0500 Subject: [PATCH 4/6] refactor: project no longer is the repository --- lib/terraform/variables.common.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/terraform/variables.common.tf b/lib/terraform/variables.common.tf index acc88a4..549d6c8 100644 --- a/lib/terraform/variables.common.tf +++ b/lib/terraform/variables.common.tf @@ -14,7 +14,7 @@ variable "image_tag" { variable "project" { type = string - description = "The repository holding the terraform for this component" + description = "The business project implementing this component" sensitive = false nullable = false } From 77160f0cef19b84cfe4ac92c543f80e5cc88f4c4 Mon Sep 17 00:00:00 2001 From: Bishop Bettini Date: Thu, 29 Dec 2022 12:29:17 -0500 Subject: [PATCH 5/6] refactor: move default up a level --- lib/terraform/variables.common.tf | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/terraform/variables.common.tf b/lib/terraform/variables.common.tf index 549d6c8..c61ee20 100644 --- a/lib/terraform/variables.common.tf +++ b/lib/terraform/variables.common.tf @@ -31,7 +31,6 @@ variable "repository" { description = "The source code repository where the component code can be found" sensitive = false nullable = false - default = "" } variable "product" { @@ -39,5 +38,4 @@ variable "product" { description = "The product supported by the component" sensitive = false nullable = false - default = "" } From 8660276ee003475e9422c9c1dc4dee3588127926 Mon Sep 17 00:00:00 2001 From: Bishop Bettini Date: Thu, 29 Dec 2022 12:31:05 -0500 Subject: [PATCH 6/6] refactor: pass in default values --- lib/deploy-env.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/deploy-env.sh b/lib/deploy-env.sh index f479af3..59b3d6f 100644 --- a/lib/deploy-env.sh +++ b/lib/deploy-env.sh @@ -19,6 +19,10 @@ TF_VAR_project="${default_TF_VAR_project:-terraform-component}" # Provide a rough idea of who's making this change TF_VAR_user="${default_TF_VAR_user:-$(whoami)@$(hostname)}" +# Expose additional common tags +TF_VAR_repository="${default_TF_VAR_repository:-}" +TF_VAR_product="${default_TF_VAR_product:-}" + # Provide a means for all components to use a common backend. Because certain # values in our backend configuration are dynamic and Terraform does not # support variables in backend configuration, we set the entire configuration