Skip to content

Commit

Permalink
add checks and inputs for business, application, and environment
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Feb 17, 2026
1 parent 549568d commit 0f73ac9
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@
- 0.3.0 -- 2026-02-17
- base-label
- add some outputs

- 0.3.1 -- 2026-02-17
- base-label
- add checking of business, application, environment
21 changes: 21 additions & 0 deletions base-label/base.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
locals {
base_variables = {
business = var.business
application = var.application
environment = var.environment
custom = var.custom
}
base = { for k in ["business", "application", "environment", "custom"] : k => try(local.base_in.base[k], try(var.base_variables[k], null)) }
}

resource "terraform_data" "base_environment" {
count = length(local.base.environment) > 0 ? 1 : 0
input = tolist(local.base.environment)

lifecycle {
precondition {
condition = contains(["dev", "test", "qa", "uat", "ite", "stage", "prod", "cre", "sa", "services", "common"], local.base.environment) || local.base.environment == null
error_message = "The var.environment or base.environment value invalid. See https://github.e.it.census.gov/terraform/cloud-information/tree/master/aws/documentation/naming-tagging-standard for valid list."
}
}
}
3 changes: 3 additions & 0 deletions base-label/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
locals {
base_in = var.filename != null && try(fileexists(var.filename), false) ? yamldecode(file(var.filename)) : yamldecode("{}")
}
32 changes: 16 additions & 16 deletions base-label/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,37 @@ output "version" {
output "core" {
description = "Map of base label format values"
value = {
business = var.business
business = var.business
application = var.application
environment = var.environment
custom = var.custom
custom = var.custom
}
}

locals {
_blf_parts = [
var.business,
var.application,
var.environment,
var.custom,
var.business,
var.application,
var.environment,
var.custom,
]
blf_parts = compact(local._blf_parts)
_blf_prefix = [
var.business,
var.application,
var.environment,
var.business,
var.application,
var.environment,
]
blf_prefix = compact(local._blf_prefix)
prefix_dash = join("-",local.blf_prefix)
prefix_slash = join("/",local.blf_prefix)
blf_prefix = compact(local._blf_prefix)
prefix_dash = join("-", local.blf_prefix)
prefix_slash = join("/", local.blf_prefix)
}

output "formats" {
description = "Map of base label format convenience outputs"
value = {
parts = local.blf_parts
prefix = local.blf_prefix
prefix_dash = local.prefix_dash
parts = local.blf_parts
prefix = local.blf_prefix
prefix_dash = local.prefix_dash
prefix_slash = local.prefix_slash
}
}
2 changes: 1 addition & 1 deletion common/version.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
locals {
_module_version = "0.3.0"
_module_version = "0.3.1"
_module_name = "boc-nts"
}

0 comments on commit 0f73ac9

Please sign in to comment.