While doing $Terraform apply got this error.
Error in function call
│
│ on .terraform/modules/cloudwatch_logs.user.label/main.tf line 5, in resource "null_resource" "default":
│ 5: id = "${lower(join(var.delimiter, compact(concat(list(var.namespace, var.stage, var.name), var.attributes))))}"
│ ├────────────────
│ │ while calling list(vals...)
│
│ Call to function "list" failed: the "list" function was deprecated
│ in Terraform v0.12 and is no longer available; use tolist([ ... ])
│ syntax to write a literal list.
╵
How to fix it?
I used cloudposse/cloudwatch_logs module in my cloudposse/codebuild/aws module and wanted to store logs in cloudwatch.
CodePudding user response:
It sounds like you might be trying to output a list of objects or create a map of some sort? Just a guess. In any case, you will need to use the tolist
function as the error indicates. Here's a link to the developer doc that may be helpful.
https://developer.hashicorp.com/terraform/language/functions/tolist
CodePudding user response:
You seem to be using version 0.4.0 of the cloudposse/label/null
module, which is very old (released in 2018) and is using a function from a long-obsolete version of Terraform.
You aren't using this module directly, though: you seem to also be using an old version of cloudposse/cloudwatch-logs/aws
which in turn has a module "user"
block and that module is the one calling cloudposse/label/null
.
To select a newer version then you will probably need to upgrade to a newer cloudposse/cloudwatch-logs/aws
release and then hopefully that will have a type constraint for selecting newer versions of the other two modules too.
The latest version of cloudposse/label/null
seems to be compatible with the latest versions of Terraform, and so once you are using a newer version you should no longer see this error. However, I am not familiar with these modules and so I don't know if upgrading will be easy or if you will need to make other changes to your configuration too.
Another option is to use a Terraform version that is of similar age to this module version. Because this module version is from 2018, the corresponding Terraform version will be one of the v0.10.x series. I expect this module will also work in v0.11.x because there are no significant language changes in that version, and so if you want to make this work without upgrading I would suggest trying with the latest v0.11.x release.
Note that Terraform v0.11.x is now very obsolete so although this will probably allow working with this very old module you should still plan to upgrade both the module and Terraform, because it will be hard to find help to maintain Terraform configurations written in such an old version of the language.