I am trying to loop over the output from some modules but can’t get the key used to create the child module
eg i create multiple modules using a list
module "services" {
for_each = var.clients
source = "./service"
...some variables
}
resource "aws_s3_bucket_notification" "bucket_notification" {
bucket = aws_s3_bucket.ftp.id
dynamic "lambda_function" {
for_each = [for s in module.services: {
name = s.**id**
lambda_arn = s.lambda_arn
}]
content {
id="updates_${lambda_function.key}"
lambda_function_arn = lambda_function.value.lambda_arn
events = ["s3:ObjectCreated:*"]
filter_prefix = "${lambda_function.value.name}/"
}
}
}
I can get the out declared in module but can’t access the ‘index’ which was used to create the modules. I have tried id, name, index but can’t access it. Is there a way to get the index?
thanks
Andy