@brianabston001 wrote:
I am currently on 0.11.14 and working to move to 0.12.18 and i hit a snag on a current code setup. I am making a data call to get the subnet ids from a vpc. See below
data "aws_subnet_ids" "task" { vpc_id = var.app_vpc_id tags = { id = "task" } }
Then I am trying to pass those subnet ids in as environment variables to a lambda function…
resource "aws_lambda_function" "function_name" { environment { variables = { SUBNET_1 = element(tolist(data.aws_subnet_ids.task.ids), count.index + 0) SUBNET_2 = element(tolist(data.aws_subnet_ids.task.ids), count.index + 1) SUBNET_3 = element(tolist(data.aws_subnet_ids.task.ids), count.index + 2) } }
This setup works fine on 0.11.14 but on 0.12.18 it is giving me an error:
SUBNET_1 = element(tolist(data.aws_subnet_ids.task.ids), count.index + 0) The "count" object can be used only in "resource" and "data" blocks, and only when the "count" argument is set. SUBNET_2 = element(tolist(data.aws_subnet_ids.task.ids), count.index + 1) The "count" object can be used only in "resource" and "data" blocks, and only when the "count" argument is set. SUBNET_2 = element(tolist(data.aws_subnet_ids.task.ids), count.index + 2) The "count" object can be used only in "resource" and "data" blocks, and only when the "count" argument is set.
Any suggestion on how I can do this in 0.12?
Posts: 3
Participants: 2