Nessuna descrizione

Frederick Damstra 571d7ccde7 Merge pull request #521 from mdr-engineering/feature/ftd_MSOCI-2349_RemoveFredsEmail 2 anni fa
base 6b04d75ef0 Changes Alert Notifications from fred to engineering 2 anni fa
scripts ab46669081 Added port 587 submission-in 3 anni fa
submodules 5713a943b8 Removes path restrictions for mdr_terraformer role 2 anni fa
thirdparty 3dadcc0a33 Updated nodejs to v16 2 anni fa
variables 8b165674ad Re-adds Colby's IP 3 anni fa
.gitattributes 5c4a96a001 Initial Commit 5 anni fa
.gitignore 5c4a96a001 Initial Commit 5 anni fa
README.md 7a08ba10cf Migrated most variables out of xdr-terraform-live and into xdr-terraform-modules 3 anni fa

README.md

modules

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.

Variables

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:

  1. If the variable only affects the module itself, just put it in the module directory.
  2. If the variable is used by more than one module, put it in the variables/ directory and create symbolic links into the modules that need it.
  3. If a variable is added to 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.
  4. When creating a new module, be sure to use cp -a instead of cp -r. cp -a will preserve symbolic links.

Variable Differentiation

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:

1. Directly during assignment

This is straightforward:

e.g.:

  instance_type = var.environment == "prod" ? "m5a.xlarge" : "t3a.micro"

2. Map with differentiator

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]
}

3. Default with Exceptions

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
}