I am trying to access or calling CSV file in code which is another folder but when I set the path showing error in terraform
following is terraform code which set path of file module is folder in that a is another one folder after that there file name is test.CSV
locals {
group_names = csvdecode(file("/modules/a/test.csv"))
}
Error: Error in function call
on VPN_Gateway\VPN_Gateway.tf line 7, in locals:
7: group_names = csvdecode(file("modules/a/test.csv"))
Call to function "file" failed: no file exists at modules\a\test.csv
When the CSV file is in another folder with multiple directory levels, then I recommend you use the absolute path for it. And you can get that path when you in the folder of the CSV file and use the command (I assume you use the Linux OS) pwd
. The possible reason that you got the error is you use the wrong relative path. It seems your CSV file is in the Terraform module directory. If your directory tree like this:
.
├── main.tf
├── modules
│ └── a
│ └── test.csv
And you load the CSV file in the root path with main.tf
file, then the code should be like this:
locals {
group_names = csvdecode(file("modules/a/test.csv"))
}
Suggest again, the absolute path is more appropriate.