Skip to content

Commit cf9e429

Browse files
committed
Move volume_tags into dynamic blocks
This effectively removes the churn-ing that is happening when an ebs_volume is attached separately from the module Takes advantage of the new feature in the aws provider available as of 3.24.0. hashicorp/terraform-provider-aws#15474
1 parent 41d41ea commit cf9e429

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

main.tf

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ resource "aws_instance" "this" {
3535
kms_key_id = lookup(root_block_device.value, "kms_key_id", null)
3636
volume_size = lookup(root_block_device.value, "volume_size", null)
3737
volume_type = lookup(root_block_device.value, "volume_type", null)
38+
tags = merge(
39+
{
40+
"Name" = var.instance_count > 1 || var.use_num_suffix ? format("%s${var.num_suffix_format}", var.name, count.index + 1) : var.name
41+
},
42+
var.volume_tags,
43+
)
3844
}
3945
}
4046

@@ -49,6 +55,12 @@ resource "aws_instance" "this" {
4955
snapshot_id = lookup(ebs_block_device.value, "snapshot_id", null)
5056
volume_size = lookup(ebs_block_device.value, "volume_size", null)
5157
volume_type = lookup(ebs_block_device.value, "volume_type", null)
58+
tags = merge(
59+
{
60+
"Name" = var.instance_count > 1 || var.use_num_suffix ? format("%s${var.num_suffix_format}", var.name, count.index + 1) : var.name
61+
},
62+
var.volume_tags,
63+
)
5264
}
5365
}
5466

@@ -92,13 +104,6 @@ resource "aws_instance" "this" {
92104
var.tags,
93105
)
94106

95-
volume_tags = merge(
96-
{
97-
"Name" = var.instance_count > 1 || var.use_num_suffix ? format("%s${var.num_suffix_format}", var.name, count.index + 1) : var.name
98-
},
99-
var.volume_tags,
100-
)
101-
102107
credit_specification {
103108
cpu_credits = local.is_t_instance_type ? var.cpu_credits : null
104109
}

versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ terraform {
22
required_version = ">= 0.12.6"
33

44
required_providers {
5-
aws = ">= 2.65"
5+
aws = ">= 3.24.0"
66
}
77
}

0 commit comments

Comments
 (0)