https://github.com/willfarrell/terraform-defaults-module
Sanitize and group common vars
https://github.com/willfarrell/terraform-defaults-module
Last synced: about 1 month ago
JSON representation
Sanitize and group common vars
- Host: GitHub
- URL: https://github.com/willfarrell/terraform-defaults-module
- Owner: willfarrell
- License: mit
- Created: 2019-06-16T20:55:47.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-11-30T15:53:11.000Z (over 6 years ago)
- Last Synced: 2025-06-03T02:45:52.681Z (9 months ago)
- Language: HCL
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```hcl-terraform
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
```hcl-terraform
resource "aws_autoscaling_group" "ec2" {
...
dynamic "tag" {
for_each = local.tags
content {
key = tag.key
value = tag.value
propagate_at_launch = true
}
}
}
```
## Refs
- https://github.com/jonbrouse/terraform-style-guide/blob/master/README.md#naming-conventions
- https://github.com/cloudposse/terraform-null-label
## TODO
- [ ] Add in Cost Center tags