Skip to content

0.2.0 Add hierarchical imports and deep-merging of configuration filess

Compare
Choose a tag to compare
@aknysh aknysh released this 08 Dec 17:30
· 40 commits to main since this release
6c35c07

what

  • Add hierarchical imports and deep-merging of configuration files
  • Add examples

why

  • Hierarchical imports - support import up to five level deep (so we can, for example, import environment globals into a stack, which in turn can import globals for the entire solution)
  • All imported maps are deepmerged into a final configuration map for consumption in other terraform modules

test of local imports and deepmerging

Outputs:

list_configs = []
map_configs = {
  "components" = {
    "helmfile" = {
      "nginx-ingress" = {
        "vars" = {
          "installed" = true
        }
      }
    }
    "terraform" = {
      "eks" = {
        "backend" = {
          "s3" = {
            "workspace_key_prefix" = "eks"
          }
        }
      }
      "vpc" = {
        "backend" = {
          "s3" = {
            "workspace_key_prefix" = "vpc"
          }
        }
        "vars" = {
          "cidr_block" = "10.102.0.0/18"
        }
      }
    }
  }
  "helmfile" = {}
  "import" = [
    "imports-level-2",
  ]
  "terraform" = {}
  "vars" = {
    "environment" = "ue2"
    "namespace" = "eg"
    "region" = "us-east-2"
    "stage" = "prod"
  }
}
yaml_config_1_imports = [
  "imports-level-2.yaml",
]
yaml_config_2_imports = [
  "imports-level-3.yaml",
]
yaml_config_3_imports = []
yaml_config_4_imports = []

test of remote imports and deepmerging

Outputs:

list_configs = []
map_configs = {
  "components" = {
    "helmfile" = {
      "nginx-ingress" = {
        "vars" = {
          "installed" = true
        }
      }
    }
    "terraform" = {
      "eks" = {
        "backend" = {
          "s3" = {
            "workspace_key_prefix" = "eks"
          }
        }
        "command" = "/usr/bin/terraform-0.13"
      }
      "vpc" = {
        "backend" = {
          "s3" = {
            "workspace_key_prefix" = "vpc"
          }
        }
        "command" = "/usr/bin/terraform-0.13"
        "vars" = {
          "cidr_block" = "10.102.0.0/18"
        }
      }
    }
  }
  "helmfile" = {}
  "import" = [
    "ue2-globals",
  ]
  "terraform" = {
    "backend" = {
      "s3" = {
        "acl" = "bucket-owner-full-control"
        "bucket" = "eg-ue2-root-tfstate"
        "dynamodb_table" = "eg-ue2-root-tfstate-lock"
        "encrypt" = true
        "key" = "terraform.tfstate"
        "region" = "us-east-2"
        "role_arn" = "arn:aws:iam::xxxxxxxx:role/eg-gbl-root-terraform"
      }
    }
    "backend_type" = "s3"
  }
  "vars" = {
    "environment" = "ue2"
    "namespace" = "eg"
    "region" = "us-east-2"
    "stage" = "prod"
  }
}
yaml_config_1_imports = [
  "https://raw.githubusercontent.com/cloudposse/atmos/master/example/stacks/ue2-globals.yaml",
]
yaml_config_2_imports = [
  "https://raw.githubusercontent.com/cloudposse/atmos/master/example/stacks/globals.yaml",
]
yaml_config_3_imports = []
yaml_config_4_imports = []