Create AWS Elastic BeanStalk with an existing Shared Load Balancer using Terraform

First of all, I really appreciate the help that you can provide me.

We have about 100 Java 8 environments on BeanStalk. We want to migrate them to Java 11, but we don’t want to do it by hand. Let’s try it with terraform.I am very new to this technology.

All of our environments use the same shared load balancer. I am trying user terraform to create an environment identical to the current ones. But it seems that the shared load balancer is not mapped correctly.

A correct environment created manually:

correcto1

But automating the environment creation, I get the following:

error1

Here the main.tf

resource “aws_elastic_beanstalk_environment” “beanstalkappenv” {
name = var.beanstalkappenv
application = “EB-PRUEBASACRUZ”
solution_stack_name = var.solution_stack_name
tier = var.tier

setting {
namespace = “aws:ec2:vpc”
name = “VPCId”
value = var.vpc_id
}
setting {
namespace = “aws:autoscaling:launchconfiguration”
name = “IamInstanceProfile”
value = “aws-elasticbeanstalk-ec2-role”
}
setting {
namespace = “aws:ec2:vpc”
name = “AssociatePublicIpAddress”
value = “False”
}

setting {
namespace = “aws:ec2:vpc”
name = “Subnets”
value = join(",", var.public_subnets)
}
setting {
namespace = “aws:elasticbeanstalk:environment”
name = “EnvironmentType”
value = “LoadBalanced”
}
setting {
namespace = “aws:elasticbeanstalk:environment”
name = “LoadBalancerType”
value = “application”
}
setting {
namespace = “aws:elasticbeanstalk:environment”
name = “LoadBalancerIsShared”
value = “True”
}
setting {
namespace = “aws:elbv2:loadbalancer”
name = “SharedLoadBalancer”
value = “arn:aws:elasticloadbalancing:eu-west-******”
}
setting {
namespace = “aws:elbv2:listener:default”
name = “ListenerEnabled”
value = “False”
}
setting {
namespace = “aws:elasticbeanstalk:environment:process:default”
name = “Port”
value = 8080
}
setting {
namespace = “aws:elasticbeanstalk:environment:process:default”
name = “Protocol”
value = “HTTP”
}
setting {
namespace = “aws:autoscaling:launchconfiguration”
name = “InstanceType”
value = var.Instance_type
}
setting {
namespace = “aws:autoscaling:asg”
name = “MinSize”
value = var.minsize
}
setting {
namespace = “aws:autoscaling:asg”
name = “MaxSize”
value = var.maxsize
}
setting {
namespace = “aws:elasticbeanstalk:healthreporting:system”
name = “SystemType”
value = “enhanced”
}

}