Skip to content

Commit

Permalink
✨ (feature): Adds new 'project' field to support label
Browse files Browse the repository at this point in the history
  • Loading branch information
bendoerr committed Sep 1, 2023
1 parent c1bcbc5 commit 94ab0ef
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/complete/complete.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ region = "us-west-2"
region_short = "uw2"
instance = "demo"
instance_short = "dmo"
project = "test"
attributes = [
"attr1"
]
Expand Down
1 change: 1 addition & 0 deletions examples/complete/ctx_full.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module "ctx_full" {
region_short = var.region_short
instance = var.instance
instance_short = var.instance_short
project = var.project
attributes = var.attributes
tags = var.tags
}
Expand Down
8 changes: 8 additions & 0 deletions examples/complete/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ variable "instance_short" {
EOT
}

variable "project" {
type = string
default = ""
description = <<-EOT
Unique identifier for this project
EOT
}

variable "attributes" {
type = list(string)
default = []
Expand Down
2 changes: 2 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ locals {
region_tags = { "Region" = local.gvn_region }
instance_tags = { "Instance" = local.gvn_instance }
context_worksp_tags = { "Workspace" = terraform.workspace }
project_tags = { "Project" = var.project }
tags = merge(
local.gvn_tags,
local.gvn_role != "" ? local.role_tags : {},
local.gvn_region != "" ? local.region_tags : {},
local.gvn_instance != "" ? local.instance_tags : {},
var.project != "" ? local.project_tags : {},
terraform.workspace != "" ? local.context_worksp_tags : {},
)
}
6 changes: 6 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ output "instance_short" {
description = "The evaluated instance"
}

output "project" {
value = var.project
description = "The evaluated project"
}

output "dns_namespace" {
value = local.dns_namespace
description = "A DNS namespace"
Expand Down Expand Up @@ -65,6 +70,7 @@ output "shared" {
instance = local.gvn_instance
instance_short = local.instance_short
namespace = local.gvn_namespace
project = var.project
tags = local.tags
}
description = "Used for sharing the context with other modules"
Expand Down
3 changes: 3 additions & 0 deletions test/examples_complete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func TestExamplesComplete(t *testing.T) {
Region_Short string
Role string
Role_Short string
Project string
Tags map[string]string
}

Expand All @@ -65,12 +66,14 @@ func TestExamplesComplete(t *testing.T) {
Region_Short: "uw2",
Role: "production",
Role_Short: "prd",
Project: "test",
Tags: map[string]string{
"ExtraTag": "ExtraTagValue",
"Instance": "demo",
"Region": "us-west-2",
"Role": "production",
"Workspace": "default",
"Project": "test",
},
},
},
Expand Down
9 changes: 9 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ variable "instance_short" {
EOT
}

variable "project" {
type = string
default = ""
description = <<-EOT
Unique identifier for this project
EOT
}

variable "attributes" {
type = list(string)
default = []
Expand All @@ -96,6 +104,7 @@ variable "context" {
region_short = ""
role = ""
role_short = ""
project = ""
tags = {}
}
description = "Allows the merging of an existing context with this one."
Expand Down

0 comments on commit 94ab0ef

Please sign in to comment.