Collection of module defaults
- name: name of application
- tags: module default tags
- account_id: Current Account ID
- region: Current AWS Region
- name: Sanitized
name - name_alphanumeric: Sanitized
namethat is only[a-zA-Z0-9](ie for AWS WAF) - tags: tags merged with defaults
variable "default_tags" {
type = "map"
default = {}
}
module "defaults" {
source = "../defaults"
name = "${var.name}"
tags = "${var.default_tags}"
}
locals {
account_id = "${module.defaults.account_id}"
region = "${module.defaults.region}"
name = "${module.defaults.name}"
tags = "${module.defaults.tags}"
}
resource "****" "main" {
...
tags = "${merge(local.tags, map(
"Name", "${local.name}-****",
"Description", "Does x"
))}"
}
resource "aws_autoscaling_group" "ec2" {
...
dynamic "tag" {
for_each = local.tags
content {
key = tag.key
value = tag.value
propagate_at_launch = true
}
}
}
- https://github.com/jonbrouse/terraform-style-guide/blob/master/README.md#naming-conventions
- https://github.com/cloudposse/terraform-null-label
- Add in Cost Center tags