Skip to content

Instantly share code, notes, and snippets.

@chilledornaments
Created January 20, 2022 14:50
Show Gist options
  • Save chilledornaments/5ecb5e74faf511190477d5a032a61b68 to your computer and use it in GitHub Desktop.
Save chilledornaments/5ecb5e74faf511190477d5a032a61b68 to your computer and use it in GitHub Desktop.
Terraform ASG tags conversion
/*
I recently wrote a Terraform module to create an ECS Capacity Provider, ASG, Launch Template, etc.
ASG tags are a `set(map(string)))`, unlike most other resources which are simply a `map(string)`.
The `local` below converts `map(string)` tags into `set(map(string)))` tags.
*/
```hcl
locals {
concat_tags = [
for k, v in var.tags : { "key" : k, "value" : v, "propagate_at_launch" : true }
]
}
resource "aws_autoscaling_group" "asg" {
...
tags = concat(
[
{...}
],
local.concat_tags
)
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment