Skip to content

willfarrell/terraform-defaults-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

defaults

Collection of module defaults

Input

  • name: name of application
  • tags: module default tags

Output

  • account_id: Current Account ID
  • region: Current AWS Region
  • name: Sanitized name
  • name_alphanumeric: Sanitized name that is only [a-zA-Z0-9] (ie for AWS WAF)
  • tags: tags merged with defaults

Use

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"
  ))}"
}

Error: ... tags: should be a list

resource "aws_autoscaling_group" "ec2" {
  ...
  dynamic "tag" {
    for_each = local.tags
    content {
      key = tag.key
      value = tag.value

      propagate_at_launch = true
    }
  }
}

Refs

TODO

  • Add in Cost Center tags

About

Sanitize and group common vars

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages