Count and for each

Hi everyone!

I believe I’m missing something here. Could please, help me to clarify it?

in the lab [Terraform Basics Training Course | KodeKloud], question 6.

The solution suggest to use the follow.

resource "local_file" "name" {
    filename = var.users[count.index]
    sensitive_content = var.content
    count = length(var.users)

}

After write that in the file [main.tf] the validation (of the question) says that the answer it is correct. However, the command [terraform plan] says different, as we can see bellow.

iac-server $ terraform plan
var.users
  Enter a value: um


Error: Variables not allowed

  on <value for var.users> line 1:
  (source code not available)

Variables may not be used here.


Error: No value for required variable

  on variables.tf line 1:
   1: variable "users" {

The root module input variable "users" is not set, and has no default value.
Use a -var or -var-file command line argument to provide a value for this
variable.

I still didn’t get this error, and am wondering, the the names of users will come from to create the resources.

Please, could you help me to find the answers?

Thank you very much.
Raul.