Skip to content

Commit 3443e22

Browse files
committed
fix: Change variable type and loop check
1 parent e53db35 commit 3443e22

File tree

6 files changed

+10
-8
lines changed

6 files changed

+10
-8
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.99.0
3+
rev: v1.99.4
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_wrapper_module_for_each

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ No modules.
414414
| <a name="input_ipam_pools"></a> [ipam\_pools](#input\_ipam\_pools) | The IPAM pools to use with the load balancer | `map(string)` | `{}` | no |
415415
| <a name="input_listeners"></a> [listeners](#input\_listeners) | Map of listener configurations to create | `any` | `{}` | no |
416416
| <a name="input_load_balancer_type"></a> [load\_balancer\_type](#input\_load\_balancer\_type) | The type of load balancer to create. Possible values are `application`, `gateway`, or `network`. The default value is `application` | `string` | `"application"` | no |
417-
| <a name="input_minimum_load_balancer_capacity"></a> [minimum\_load\_balancer\_capacity](#input\_minimum\_load\_balancer\_capacity) | Minimum capacity for a load balancer. Only valid for Load Balancers of type `application` or `network` | `number` | `null` | no |
417+
| <a name="input_minimum_load_balancer_capacity"></a> [minimum\_load\_balancer\_capacity](#input\_minimum\_load\_balancer\_capacity) | Minimum capacity for a load balancer. Only valid for Load Balancers of type `application` or `network` | `any` | `{}` | no |
418418
| <a name="input_name"></a> [name](#input\_name) | The name of the LB. This name must be unique within your AWS account, can have a maximum of 32 characters, must contain only alphanumeric characters or hyphens, and must not begin or end with a hyphen | `string` | `null` | no |
419419
| <a name="input_name_prefix"></a> [name\_prefix](#input\_name\_prefix) | Creates a unique name beginning with the specified prefix. Conflicts with `name` | `string` | `null` | no |
420420
| <a name="input_preserve_host_header"></a> [preserve\_host\_header](#input\_preserve\_host\_header) | Indicates whether the Application Load Balancer should preserve the Host header in the HTTP request and send it to the target without any change. Defaults to `false` | `bool` | `null` | no |

examples/complete-alb/main.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ module "alb" {
7171
ipv4_ipam_pool_id = aws_vpc_ipam_pool.this.id
7272
}
7373

74-
minimum_load_balancer_capacity = 10
74+
minimum_load_balancer_capacity = {
75+
capacity_units = 10
76+
}
7577

7678
client_keep_alive = 7200
7779

main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ resource "aws_lb" "this" {
4040
}
4141

4242
dynamic "minimum_load_balancer_capacity" {
43-
for_each = var.minimum_load_balancer_capacity != null ? [var.minimum_load_balancer_capacity] : []
43+
for_each = length(var.minimum_load_balancer_capacity) > 0 ? [var.minimum_load_balancer_capacity] : []
4444

4545
content {
46-
capacity_units = minimum_load_balancer_capacity.value
46+
capacity_units = minimum_load_balancer_capacity.value.capacity_units
4747
}
4848
}
4949

variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ variable "enforce_security_group_inbound_rules_on_private_link_traffic" {
136136

137137
variable "minimum_load_balancer_capacity" {
138138
description = "Minimum capacity for a load balancer. Only valid for Load Balancers of type `application` or `network`"
139-
type = number
140-
default = null
139+
type = any
140+
default = {}
141141
}
142142

143143
variable "name" {

wrappers/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module "wrapper" {
3030
ipam_pools = try(each.value.ipam_pools, var.defaults.ipam_pools, {})
3131
listeners = try(each.value.listeners, var.defaults.listeners, {})
3232
load_balancer_type = try(each.value.load_balancer_type, var.defaults.load_balancer_type, "application")
33-
minimum_load_balancer_capacity = try(each.value.minimum_load_balancer_capacity, var.defaults.minimum_load_balancer_capacity, null)
33+
minimum_load_balancer_capacity = try(each.value.minimum_load_balancer_capacity, var.defaults.minimum_load_balancer_capacity, {})
3434
name = try(each.value.name, var.defaults.name, null)
3535
name_prefix = try(each.value.name_prefix, var.defaults.name_prefix, null)
3636
preserve_host_header = try(each.value.preserve_host_header, var.defaults.preserve_host_header, null)

0 commit comments

Comments
 (0)