|
2 anos atrás | |
---|---|---|
base | 2 anos atrás | |
scripts | 3 anos atrás | |
submodules | 2 anos atrás | |
thirdparty | 2 anos atrás | |
variables | 3 anos atrás | |
.gitattributes | 5 anos atrás | |
.gitignore | 5 anos atrás | |
README.md | 3 anos atrás |
This directory contains modules that are included from the environment directories.
Modules called from other modules should be placed under the submodules
subdirectory.
Modules called from other modules should be placed under the thirdparty
subdirectory.
Added 2022-06-10
Variables that affect configuration and are subject to change exist with the modules. There are a few important things to know:
variables/
directory and create symbolic links into the modules that need it.xdr-terraform-live
, it should be one that is set once and never changes. These variables can be found in the constants.tf
file under variables/
, and is linked into all modules.cp -a
instead of cp -r
. cp -a
will preserve symbolic links.Since we still want different settings base on things like environment or account, there are a few "tropes" used to provide this differentiation.
From easiest to most complex, the 3 methods most often employed are as follows. Note that in these examples, all 3 produce the same result:
This is straightforward:
e.g.:
instance_type = var.environment == "prod" ? "m5a.xlarge" : "t3a.micro"
This method creates a map of values, and selects the appropriate one immediately. This is good for things that will always have a value.
e.g.:
locals {
instance_type = {
prod = "m5a.xlarge",
test = "t3a.micro",
}[var.environment]
}
This method sets a default value, creates a map of exceptions, and then does a lookup
to determine the final value. This is useful when the same value will be used most of the time, but it can be overridden in certain cases.
e.g.
locals {
instance_type_default = "m5a.xlarge"
instance_type_exceptions = {
afs-mdr-test-c2-gov = "t3a.micro"
afs-mdr-test-malware-gov = "t3a.micro"
}
instance_type = lookup(local.instance_type_exceptions, var.account_name, local.instance_type_default
}