Terraform module to provide consistent label names and tags for resources.
A single name format will not solve every use case, so multiple variants are returned and there is a few options to affect how they get build. The general name convention is {organization}-{environment}-{name}-{attributes}
. Name
is required, the other 3 can be turned on/off individually. The delimiter (-
) can be changed
All devops-workflow modules will eventually use this.
NOTE: local
refers to this using locals and does not create any resources. It just builds new variables.
Terraform registry: https://registry.terraform.io/modules/devops-workflow/label/local
module "name" {
source = "devops-workflow/label/local"
version = "0.1.2"
name = "name"
environment = "qa"
}
This will create an id
with the value of qa-name
module "s3-name" {
source = "devops-workflow/label/local"
version = "0.1.2"
name = "data"
environment = "qa"
organization = "corp"
namespace-org = "true"
}
This will create an id
with the value of corp-qa-data
Now reference label
outputs to create the S3 bucket
resource "aws_s3_bucket" "data" {
bucket = "${module.s3-name.id}"
tags = "${module.s3-name.tags}"
}
Using in a module and exposing all settings to upstream caller.
module "label" {
source = "devops-workflow/label/local"
version = "0.1.2"
organization = "${var.organization}"
name = "${var.name}"
namespace-env = "${var.namespace-env}"
namespace-org = "${var.namespace-org}"
environment = "${var.environment}"
delimiter = "${var.delimiter}"
attributes = "${var.attributes}"
tags = "${var.tags}"
}