Error: error describing ELBv2 Listener
When applying a terraform change that alters the behavior or tags of an Application Loadbalancer or Classic Load Balancer (net) you may face
ALB log
│ Error: error describing ELBv2 Listener (arn:aws:elasticloadbalancing:us-east-1:111111111111:loadbalancer/app/alb-x-y-z/id-x): ValidationError: 'arn:aws:elasticloadbalancing:us-east-1:111111111111:loadbalancer/app/alb-x-y-z/id-x' is not a valid listener ARN
│ status code: 400, request id: abcedef-gh55-491e-94e8-12aebetaet32
Classic Load Balancer / Network Load Balancer log
│ Error: error describing ELBv2 Listener (arn:aws:elasticloadbalancing:us-east-1:111111111111:loadbalancer/net/net-x-y-z/id-x): ValidationError: 'arn:aws:elasticloadbalancing:us-east-1:111111111111:loadbalancer/net/net-x-y-z/id-x' is not a valid listener ARN
│ status code: 400, request id: abcedef-gh54-491e-94e8-12aebetaet31
Context
The error is usually present on versions 3 and up to 4.12 of the AWS provider as some api endpoints have changed rendering the issue.
It was fixed in the provider 4.12, that can be seen here fix
So in order to fix this solution you would change your versions.tf to something like this.
1
2
3
4
5
6
7
8
9
terraform {
required_version = "~> 1.3"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.12"
}
}
}
Followed by a reinit with an upgrade version of the provider
1
terraform init -upgrade
Caveats
Upgrading the AWS provider to a major version, may result in unexpected errors with modules in use or resources.
You may also detect drifts that come from new resource attributes that were not existing before, but also should not have actual changes are usually new defaults that were already in use by the AWS resource itself.
Conclusion
This fix has a serious drawback when bumping from 3 to 4.12+ versions of the AWS provider given the unknown behavior of some resources, but should in the majority of the cases the solution to follow.