Skip to content

Commit

Permalink
chore(tflint): fix linting issues (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
saefty authored Dec 13, 2023
1 parent 595002a commit 423064d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
7 changes: 4 additions & 3 deletions alb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ resource "aws_alb_target_group" "main" {

vpc_id = var.vpc_id
port = lookup(var.target_groups[count.index], "backend_port", null)
protocol = lookup(var.target_groups[count.index], "backend_protocol", null) != null ? upper(lookup(var.target_groups[count.index], "backend_protocol")) : null
protocol_version = lookup(var.target_groups[count.index], "protocol_version", null) != null ? upper(lookup(var.target_groups[count.index], "protocol_version")) : null
protocol = lookup(var.target_groups[count.index], "backend_protocol", null) != null ? upper(lookup(var.target_groups[count.index], "backend_protocol", null)) : null
protocol_version = lookup(var.target_groups[count.index], "protocol_version", null) != null ? upper(lookup(var.target_groups[count.index], "protocol_version", null)) : null
target_type = lookup(var.target_groups[count.index], "target_type", null)

deregistration_delay = lookup(var.target_groups[count.index], "deregistration_delay", null)
Expand All @@ -23,7 +23,8 @@ resource "aws_alb_target_group" "main" {

dynamic "health_check" {
for_each = length(keys(lookup(var.target_groups[count.index], "health_check", {}))) == 0 ? [] : [
lookup(var.target_groups[count.index], "health_check", {})]
lookup(var.target_groups[count.index], "health_check", {})
]

content {
enabled = lookup(health_check.value, "enabled", null)
Expand Down
12 changes: 6 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ locals {
[
{
# allow backend_port traffic
from_port = lookup(target, "backend_port")
to_port = lookup(target, "backend_port")
from_port = lookup(target, "backend_port", null)
to_port = lookup(target, "backend_port", null)
protocol = "tcp"
source_security_group_id = tolist(data.aws_lb.public[lookup(target, "load_balancer_arn")].security_groups)[0]
source_security_group_id = tolist(data.aws_lb.public[lookup(target, "load_balancer_arn", null)].security_groups)[0]
prefix = "backend_port"
}
],
lookup(target, "health_check", null) != null &&
lookup(target["health_check"], "port", "traffic-port") != lookup(target, "backend_port", ) &&
lookup(target["health_check"], "port", "traffic-port") != lookup(target, "backend_port", null) &&
lookup(target["health_check"], "port", "traffic-port") != "traffic-port"
? [
{
# if health_check_port set and different from backend_port, also allow traffic
from_port = target["health_check"]["port"]
to_port = target["health_check"]["port"]
protocol = "tcp"
source_security_group_id = tolist(data.aws_lb.public[lookup(target, "load_balancer_arn")].security_groups)[0]
source_security_group_id = tolist(data.aws_lb.public[lookup(target, "load_balancer_arn", null)].security_groups)[0]
prefix = "health_check_port"
}
] : []
Expand Down Expand Up @@ -268,7 +268,7 @@ resource "aws_appautoscaling_policy" "ecs" {
service_namespace = aws_appautoscaling_target.ecs[count.index].service_namespace

target_tracking_scaling_policy_configuration {
target_value = lookup(var.appautoscaling_settings, "target_value")
target_value = lookup(var.appautoscaling_settings, "target_value", null)
disable_scale_in = lookup(var.appautoscaling_settings, "disable_scale_in", false)
scale_in_cooldown = lookup(var.appautoscaling_settings, "scale_in_cooldown", 300)
scale_out_cooldown = lookup(var.appautoscaling_settings, "scale_out_cooldown", 30)
Expand Down

0 comments on commit 423064d

Please sign in to comment.