Skip to content

Commit 0ab5259

Browse files
authored
Merge pull request #20 from DNXLabs/bugfix/asg-default-tags
fix: asg resource does not automatically add the default_tags from the AWS provider
2 parents 8d8d9d1 + 0bf8fc8 commit 0ab5259

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

_data.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
data "aws_region" "current" {}
22

3+
data "aws_default_tags" "current" {}
4+
35
data "aws_ami" "amazon-linux-2" {
46
most_recent = true
57
owners = ["amazon"]

asg.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
locals {
2+
all_tags = merge(
3+
coalesce(data.aws_default_tags.current.tags, {}),
4+
var.tags
5+
)
6+
}
7+
18
resource "aws_autoscaling_group" "asg" {
29
count = var.instance_count
310
name = "${var.name}-${count.index}"
@@ -27,6 +34,16 @@ resource "aws_autoscaling_group" "asg" {
2734

2835
}
2936

37+
dynamic "tag" {
38+
for_each = local.all_tags
39+
40+
content {
41+
key = tag.key
42+
value = tag.value
43+
propagate_at_launch = true
44+
}
45+
}
46+
3047
tag {
3148
key = "Name"
3249
value = var.name

0 commit comments

Comments
 (0)