The env0 module uses a 1:1 relationship, so for every environment there will be a corresponding template. This mirrors the way we build our code where each environment has it's own folder with it's own terraform code. In fact, Env0 requires that the template refers to actual code that we are going to run, so this 1:1 relationship is dictated by our architecture.
This module consumes an edited map of data generated from the global module via the data
input. Two keys need to be
injected in (one for the triggers and one for the path to the template) and the map needs to be filtered to relevant
contexts. Triggers are required to be in glob format. I recommend
adding an empty path key in the default context in quadpay-devops/terraform/modules/global/context.tf
then adding keys
in the relevant contexts like:
locals {
//contexts are to be defined as <country>-<az slug>-<env>
ctxt = {
default = {
#..
root-private-link-zones = ""
#...
}
#...
us-eastus-prd = {
#..
root-private-link-zones = "terraform/environments/production/private-link-zones"
#..
}
#...
}
}
This populates the local.all
map with everything you need to both find the code Env0 needs to run, and filter the
environments. You can inject needed keys and filter by doing the following:
locals {
all-private-link-zones = { for context, v in local.all : context =>
merge(
v,
{
env0-triggers = "+(${lookup(v, "root-private-link-zones", "")}/**)"
},
{
env0-template-root = "${lookup(v, "root-private-link-zones", "")}"
}
)
if length(lookup(v, "root-private-link-zones", "")) > 0
}
}
module "private-link-zones" {
source = "./modules/environment"
providers = {
env0 = env0
}
name-suffix = "private-link-zones"
data = local.all-private-link-zones
github-id = local.github-id
repo = module.global.repo
terraform-version = "1.1.3"
}
Name | Version |
---|---|
terraform | ~> 1.0.5 |
env0 | 0.0.22 |
Name | Version |
---|---|
env0 | 0.0.22 |
No modules.
Name | Type |
---|---|
env0_environment.example | resource |
env0_template.template | resource |
env0_template_project_assignment.assignment | resource |
Name | Description | Type | Default | Required |
---|---|---|---|---|
data | Map of data with triggers (env0-triggers) and root (env0-template-root) injected in | map(any) |
n/a | yes |
github-id | Env0 id for the Github repo for the template | number |
n/a | yes |
name-suffix | templates and environment names will have this appended to them like {each.key}- | string |
n/a | yes |
repo | url to the github repo ex: https://github.com/quadpay/quadpay-devops | string |
n/a | yes |
revision | git branch the code resides on | string |
"master" |
no |
terraform-version | The version of terraform that should run your project. Not to be confused with the version of Terraform that will build the Env0 project/template/environment/variables |
string |
"1.0.5" |
no |
Name | Description |
---|---|
environments | n/a |
templates | n/a |