Skip to content

Commit

Permalink
Update to latest null-label
Browse files Browse the repository at this point in the history
  • Loading branch information
aknysh committed Aug 21, 2021
1 parent b82fd63 commit 3bf70a5
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions modules/stack/main.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
module "always" {
source = "cloudposse/label/null"
version = "0.25.0"

# Always enable the `stack` module even if `module.this.context` sets `enabled=false`,
# because we always need to be able to create stack names even if a top-level calling module is disabled
# (if we want to set `enabled=false` on the top-level modules and then use `terraform apply` to destroy it)
enabled = true

context = module.this.context
}

locals {
descriptor_stack = lookup(module.this.descriptors, "stack", null)
descriptor_stack = lookup(module.always.descriptors, "stack", null)

# If `var.stack` is provided, return it.
# Else, if `descriptors["stack"]` is specified, use it.
# Otherwise, construct the stack name from the provided `context`.
stack_name = var.stack != null ? var.stack : (
local.descriptor_stack != null ? local.descriptor_stack : (
module.this.tenant != null ? format("%s-%s-%s", module.this.tenant, module.this.environment, module.this.stage) : (
module.always.tenant != null ? format("%s-%s-%s", module.always.tenant, module.always.environment, module.always.stage) : (
# Default stack name from `environment` and `stage`
format("%s-%s", module.this.environment, module.this.stage)
format("%s-%s", module.always.environment, module.always.stage)
)
)
)
Expand Down

0 comments on commit 3bf70a5

Please sign in to comment.