how to get element() to accept nested list elements

322 views
Skip to first unread message

Sam Lee

unread,
Aug 15, 2016, 5:58:06 PM8/15/16
to Terraform

└── custom_provider

    └── sample.0

      ├── ip_addresses.0   <- want element() to pull the first ip address

      └── ip_addresses.1

    └── sample.1

      ├── ip_addresses.0   <- want element() to pull the first ip address

      └── ip_addresses.1


resource "aws_route53_record” "foo" {

  count   = "${var.num_instances}"

  [...]

  records = ["${element(custom_instance.sample.*.ip_addresses.0, count.index)}"]  <= `terraform plan` errors

}


output "private_ip" {

  value = [ “${custom_instance.sample.*.ip_addresses.0}" ]

}


`terraform plan` errors with


Error running plan: 1 error(s) occurred:


* Resource ‘custom_instance.sample' does not have attribute 'ip_addresses.0' for variable ‘custom_instance.sample.*.ip_addresses.0'




ip_addresses is a list of strings as defined as in my custom provider:


"ip_addresses": &schema.Schema{

  Type:     schema.TypeList,

  Optional: true,

  Computed: true,

  Elem:     &schema.Schema{Type: schema.TypeString},

},

Sam Lee

unread,
Aug 22, 2016, 4:40:57 PM8/22/16
to Terraform
Reply all
Reply to author
Forward
0 new messages