if my aws_lb_target_group_attachment it is an ECS, which target type should be used at resource “aws_lb_target_group” ?.
thanks a lot
if my aws_lb_target_group_attachment it is an ECS, which target type should be used at resource “aws_lb_target_group” ?.
thanks a lot
i have done
I have 2 modules, ALB, and fargate
##############
resource “aws_ecs_service” “main” {
#count = “${var.nometaskdefenitionsem_mont ? 1 : 0}”
#task_definition = “${aws_ecs_task_definition.ldap[count.index].arn}”
name = var.nometaskdefenition
cluster = aws_ecs_cluster.ldap.id
task_definition = “${aws_ecs_task_definition.ldap.arn}”
desired_count = 1
deployment_minimum_healthy_percent = 50
deployment_maximum_percent = 200
launch_type = “FARGATE”
scheduling_strategy = “REPLICA”
network_configuration {
security_groups = ["${var.SG_1}"]
subnets = [var.subnet_id]
}
#target_group_arn = “${aws_lb_target_group.ALB_TG.id}” aqui
load_balancer {
target_group_arn = var.aws_alb_target_group_arn
container_name = var.container_definitions_name
container_port = var.container_port
}
depends_on = [
aws_lb_listener.http
]
/*
lifecycle {
ignore_changes = [task_definition, desired_count]
}*/
platform_version = “1.4.0”
}
############################################
resource “aws_lb_target_group_attachment” “apitest” {
target_group_arn = aws_lb_target_group.ALB_TG.arn
target_id = var.final_ecs_servico_id
port = 443
}
#########################################
resource “aws_lb_target_group” “ALB_TG” {
name_prefix = var.nomedoALB
port = 80
protocol = “HTTP”
vpc_id = var.final_vpc_id
deregistration_delay = 10
target_type = “ip”
health_check {
healthy_threshold = 2
unhealthy_threshold = 2
interval = 10
}
lifecycle {
create_before_destroy = true
}
}
################################################
FROM terraform apply output
cluster = “arn:aws:ecs:eu-west-3:920768381054:cluster/80”
deployment_maximum_percent = 200
deployment_minimum_healthy_percent = 50
desired_count = 1
enable_ecs_managed_tags = false
iam_role = (known after apply)
id = (known after apply)
launch_type = “FARGATE”
name = “ldap_cross”
platform_version = “1.4.0”
scheduling_strategy = “REPLICA”
task_definition = “arn:aws:ecs:eu-west-3:920768381054:task-definition/fs-e22e0353:1”
wait_for_steady_state = false
load_balancer {
network_configuration {
arn = (known after apply)
id = (known after apply)
load_balancer_arn = “arn:aws:elasticloadbalancing:eu-west-3:920768381054:loadbalancer/app/ALB/0a6bf1cd2e1249ab”
port = 80
protocol = “HTTP”
ssl_policy = (known after apply)
default_action {
cluster = “arn:aws:ecs:eu-west-3:920768381054:cluster/80”
deployment_maximum_percent = 200
deployment_minimum_healthy_percent = 50
desired_count = 1
enable_ecs_managed_tags = false
iam_role = (known after apply)
id = (known after apply)
launch_type = “FARGATE”
name = “sigom-net-core”
platform_version = “1.4.0”
scheduling_strategy = “REPLICA”
task_definition = (known after apply)
wait_for_steady_state = false
load_balancer {
network_configuration {
error message:
Error:2021-04-09T15:16:27.296+0100 [WARN] plugin.stdio: received EOF, stopping recv loop: err=“rpc error: code = Unavailable desc = transport is closing”
Error registering targets with target group: ValidationError: The IP address ‘arn:aws:ecs:eu-west-2:920768381054:service/80/ldap_cross’ is not a valid IPv4 address
status code: 400, request id: ba54f89f-7099-4ce5-8901-29e99f533531
Error: Error registering targets with target group: ValidationError: The IP address ‘arn:aws:ecs:eu-west-2:920768381054:service/80/ldap_cross’ is not a valid IPv4 address
status code: 400, request id: 6bab9d51-078f-4efa-94c5-52a51800ad50