Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Terraform Inappropriate value for attribute "subnets": element 0: string required

Tags:

terraform

I am upgrading from tf 11 to tf 12. I've run into the issue where terraform plan produces the following error:

Error: Incorrect attribute value type

   4:   subnets         = ["${var.alb_subnets}"]

Inappropriate value for attribute "subnets": element 0: string required.

The code snippet for this error is:

resource aws_alb "alb" {
  name            = "ecs-${var.app_name}"
  internal        = "${var.internal}"
  subnets         = ["${var.alb_subnets}"]
  security_groups = ["${var.security_groups}"]
  count           = "${var.do_module}"
}

If anyone can help me with this I would appreciate it.

like image 952
Evan Gertis Avatar asked Jan 23 '26 06:01

Evan Gertis


1 Answers

Change subnets = ["${var.alb_subnets}"] to subnets = var.alb_subnets

Its a update in terraform v0.12

Reference: https://www.terraform.io/upgrade-guides/0-12.html#referring-to-list-variables

like image 87
Rahul juneja - DevOps Avatar answered Jan 26 '26 00:01

Rahul juneja - DevOps



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!