Skip to content

Commit eafbf1c

Browse files
authored
fix: root_block_device tags conflicts (#220)
1 parent 9e72732 commit eafbf1c

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ No modules.
113113
| <a name="input_disable_api_termination"></a> [disable\_api\_termination](#input\_disable\_api\_termination) | If true, enables EC2 Instance Termination Protection | `bool` | `false` | no |
114114
| <a name="input_ebs_block_device"></a> [ebs\_block\_device](#input\_ebs\_block\_device) | Additional EBS block devices to attach to the instance | `list(map(string))` | `[]` | no |
115115
| <a name="input_ebs_optimized"></a> [ebs\_optimized](#input\_ebs\_optimized) | If true, the launched EC2 instance will be EBS-optimized | `bool` | `false` | no |
116+
| <a name="input_enable_volume_tags"></a> [enable\_volume\_tags](#input\_enable\_volume\_tags) | Whether to enable volume tags (if enabled it conflicts with root\_block\_device tags) | `bool` | `true` | no |
116117
| <a name="input_ephemeral_block_device"></a> [ephemeral\_block\_device](#input\_ephemeral\_block\_device) | Customize Ephemeral (also known as Instance Store) volumes on the instance | `list(map(string))` | `[]` | no |
117118
| <a name="input_get_password_data"></a> [get\_password\_data](#input\_get\_password\_data) | If true, wait for password data to become available and retrieve it. | `bool` | `false` | no |
118119
| <a name="input_iam_instance_profile"></a> [iam\_instance\_profile](#input\_iam\_instance\_profile) | The IAM Instance Profile to launch the instance with. Specified as the name of the Instance Profile. | `string` | `""` | no |
@@ -130,7 +131,7 @@ No modules.
130131
| <a name="input_placement_group"></a> [placement\_group](#input\_placement\_group) | The Placement Group to start the instance in | `string` | `""` | no |
131132
| <a name="input_private_ip"></a> [private\_ip](#input\_private\_ip) | Private IP address to associate with the instance in a VPC | `string` | `null` | no |
132133
| <a name="input_private_ips"></a> [private\_ips](#input\_private\_ips) | A list of private IP address to associate with the instance in a VPC. Should match the number of instances. | `list(string)` | `[]` | no |
133-
| <a name="input_root_block_device"></a> [root\_block\_device](#input\_root\_block\_device) | Customize details about the root block device of the instance. See Block Devices below for details | `list(map(string))` | `[]` | no |
134+
| <a name="input_root_block_device"></a> [root\_block\_device](#input\_root\_block\_device) | Customize details about the root block device of the instance. See Block Devices below for details | `list(any)` | `[]` | no |
134135
| <a name="input_source_dest_check"></a> [source\_dest\_check](#input\_source\_dest\_check) | Controls if traffic is routed to the instance when the destination address does not match the instance. Used for NAT or VPNs. | `bool` | `true` | no |
135136
| <a name="input_subnet_id"></a> [subnet\_id](#input\_subnet\_id) | The VPC Subnet ID to launch in | `string` | `""` | no |
136137
| <a name="input_subnet_ids"></a> [subnet\_ids](#input\_subnet\_ids) | A list of VPC Subnet IDs to launch in | `list(string)` | `[]` | no |

examples/basic/main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,14 @@ module "ec2" {
9090

9191
user_data_base64 = base64encode(local.user_data)
9292

93+
enable_volume_tags = false
9394
root_block_device = [
9495
{
9596
volume_type = "gp2"
9697
volume_size = 10
98+
tags = {
99+
Name = "my-root-block"
100+
}
97101
},
98102
]
99103

main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ resource "aws_instance" "this" {
9393
var.tags,
9494
)
9595

96-
volume_tags = merge(
96+
volume_tags = var.enable_volume_tags ? merge(
9797
{
9898
"Name" = var.instance_count > 1 || var.use_num_suffix ? format("%s${var.num_suffix_format}", var.name, count.index + 1) : var.name
9999
},
100100
var.volume_tags,
101-
)
101+
) : null
102102

103103
credit_specification {
104104
cpu_credits = local.is_t_instance_type ? var.cpu_credits : null

variables.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ variable "tags" {
145145
default = {}
146146
}
147147

148+
variable "enable_volume_tags" {
149+
description = "Whether to enable volume tags (if enabled it conflicts with root_block_device tags)"
150+
type = bool
151+
default = true
152+
}
153+
148154
variable "volume_tags" {
149155
description = "A mapping of tags to assign to the devices created by the instance at launch time"
150156
type = map(string)
@@ -153,7 +159,7 @@ variable "volume_tags" {
153159

154160
variable "root_block_device" {
155161
description = "Customize details about the root block device of the instance. See Block Devices below for details"
156-
type = list(map(string))
162+
type = list(any)
157163
default = []
158164
}
159165

0 commit comments

Comments
 (0)