-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend configuration inheritance implementation
This commit moves the implementation of the configuration inheritance into a shared module and extends it to support two commonly requested use-cases. 1. Support for custom names instead of apps and ops, fix #126 2. Support for more than two infrastructure environments The module expects two input variables, `configuration` and `base_key`. `configuration` is a map of maps, and `base_key` sets the key in the configuration map that all other keys will inherit from. So, with the frameworks default apps and ops inheritance and configuration, it has the exact same behavior as before. Ops inherits from apps and overwrites values. But given a Terraform configuration with different and more keys: ``` locals { cfg = { "a" = { "a" = "a" "b" = null } "b" = { "b" = "b" } "c" = { "c" = "c" } } } module "configuration" { source = "../common/configuration" configuration = local.cfg base_key = "a" } output "merged_cfg" { value = module.configuration.merged } ``` The merged_cfg output will be: ``` merged_cfg = { "a" = { "a" = "a" } "b" = { "a" = "a" "b" = "b" } "c" = { "a" = "a" "c" = "c" } } ``` Until futher notice the framework documents and tests only the apps and ops case. So, here be dragons, you've been warned. But users can now adjust environment names and number to their liking. Provided they also align the the tagging strategy and triggers in the pipeline accordingly.
- Loading branch information
Showing
11 changed files
with
84 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
locals { | ||
base = { | ||
(var.base_key) = var.configuration[var.base_key] | ||
} | ||
|
||
overlays = { | ||
for name, _ in var.configuration : | ||
name => merge(var.configuration[var.base_key], var.configuration[name]) | ||
if name != var.base_key | ||
} | ||
} | ||
|
||
output "merged" { | ||
value = merge(local.base, local.overlays) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
variable "configuration" { | ||
type = map(map(string)) | ||
description = "Map with per workspace cluster configuration." | ||
} | ||
|
||
variable "base_key" { | ||
type = string | ||
description = "The key in the configuration map all other keys inherit from." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
terraform { | ||
required_version = ">= 0.12" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters