Skip to content

Commit fb03e6f

Browse files
committed
fix: make root_block_device dynamic
1 parent cb9c8c3 commit fb03e6f

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ module "app_cluster" {
2828
root_block_device = {
2929
volume_type = "gp3"
3030
volume_size = 30
31-
tags = {
32-
"Environment" = "staging"
33-
"ManagedBy" = "Terraform"
34-
}
3531
}
3632
security_group_ids = ["sg-01", "sg-02"]
3733
},
@@ -172,7 +168,7 @@ No modules.
172168
| launch_configs.user_data_base64 | Base64 encoded userdata. | `string` | n/a | yes |
173169
| launch_configs.iam_instance_profile_name | Name of the IAM instance profile to attach to the EC2 instance. | `string` | n/a | yes |
174170
| launch_configs.security_group_ids | List of security group ids to attach to the EC2 instance. | `list(string)` | n/a | yes |
175-
171+
| launch_configs.root_block_device | root block device configuration
176172

177173
### Outputs
178174
No outputs.

auto_scaling_groups.tf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ resource "aws_launch_configuration" "ecs_launch_config" {
55
instance_type = each.value.instance_type
66
user_data_base64 = each.value.user_data_base64
77
iam_instance_profile = each.value.iam_instance_profile_name
8-
root_block_device = each.value.root_block_device || {}
8+
9+
dynamic "root_block_device" {
10+
for_each = each.value.root_block_device != null ? [each.value.root_block_device] : []
11+
12+
content {
13+
volume_type = root_block_device.value.volume_type
14+
volume_size = root_block_device.value.volume_size
15+
}
16+
}
917
security_groups = each.value.security_group_ids
1018
lifecycle {
1119
create_before_destroy = true

variables.tf

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,8 @@ variable "launch_configs" {
4141
user_data_base64 = string
4242
iam_instance_profile_name = string
4343
root_block_device = object({
44-
ebs_volume_type = string
45-
ebs_volume_size = number
46-
tags = object({
47-
Name = string
48-
Environment = string
49-
ManagedBy = string
50-
})
44+
volume_type = string
45+
volume_size = number
5146
})
5247
security_group_ids = list(string)
5348
}))

0 commit comments

Comments
 (0)