Home > Back-end >  Terraform import returns Invalid ARN while importing ELB of type classic
Terraform import returns Invalid ARN while importing ELB of type classic

Time:08-09

I am trying to import an classic load balancer which has been created manually.

The command that I am using

terraform import aws_lb.[lb_name] arn:aws:elasticloadbalancing:[region]:[account_id]:loadbalancer/[lb_name]

the error that i am getting

 aws_lb.[lb_name]: Importing from ID "arn:aws:elasticloadbalancing:eu-west-1:[account_id]:loadbalancer/[lb_name]"...
aws_lb.[lb_name]: Import prepared!
  Prepared aws_lb for import
aws_lb.[lb_name]: Refreshing state... [id=arn:aws:elasticloadbalancing:eu-west-1:[account_id]:loadbalancer/[lb_name]
╷
│ Error: retrieving ALB (arn:aws:elasticloadbalancing:eu-west-1:[account_id]:loadbalancer/[lb_name]): ValidationError: 'arn:aws:elasticloadbalancing:eu-west-1:[account_id]:loadbalancer/[lb_name]' is not a valid load balancer ARN
│       status code: 400, request id: bb8dc4b4-4c02-4883-950b-9e4b5e6fc947
│
│
╵

What could be causing this? And, Is it possible to retrieve the ARN of an ELB?

CodePudding user response:

Because you are using Classic Load Balancer which is the previous generation, it basically does not have ARN. I am using the name instead, below mine name is binh-test-clb.

Here is my Terraform resource:

resource "aws_elb" "clb" {
  # (resource arguments)
}

Here is my import command:

terraform import aws_elb.clb binh-test-clb

References:

  • Related