Hello guys,
I try to create a aws_lb and i get an error that i dont know how to fix it.
Error: creating ELBv2 application Load Balancer (test-lb-web-net-2024): ValidationError: You cannot provide subnets from multiple locales.
│ status code: 400, request id: bbd71767-bf15-4e21-9f1f-b71ab8dcb71a
My code:
resource "aws_lb" "nginx" {
name = "test-lb-web-net-2024"
internal = false
load_balancer_type = "application"
security_groups = [aws_security_group.alb_sg.id]
subnets = [aws_subnet.public_subnet0.id, aws_subnet.public_subnet1.id]
#subnets = aws_subnet.public_subnet[*].id
#depends_on = [aws_s3_bucket.public-access]
enable_deletion_protection = false
tags = local.common_tags
/* access_logs {
bucket = aws_s3_bucket.public-access.bucket
prefix = "alb-logs"
enabled = true
} */
}
resource "aws_subnet" "public_subnet0" {
cidr_block = var.vpc_public_subnets_cidr_block[0]
vpc_id = aws_vpc.app.id
map_public_ip_on_launch = var.map_public_ip_on_launch
availability_zone = data.aws_availability_zones.available.names[0]
tags = {
Name = "public_subnet0"
}
}
resource "aws_subnet" "public_subnet1" {
cidr_block = var.vpc_public_subnets_cidr_block[1]
vpc_id = aws_vpc.app.id
map_public_ip_on_launch = var.map_public_ip_on_launch
availability_zone = data.aws_availability_zones.available.names[1]
tags = {
Name = "public_subnet1"
}
}
my locals are not related subnets, so here it is what i have in my locals file:
locals {
common_tags = {
Name = "${var.company} - ${var.project}"
company = var.company
project = "${var.company}-${var.project}"
billing_code = var.billing_code
}
#s3_bucket_name = "web-net-app-andreiweb-${random_integer.s3.result}"
s3_bucket_name = "web-net-app-andreiweb-asdasgjabslkjb123125jasasdjasb}"
}
resource "random_integer" "s3" {
min = 10000000
max = 99999999
}