I am trying to first generate in Terraform some files in a folder and then list those files. Unfortunately, I am not able to get the file list from the generation command since it is a shell script which does not outputs anything. As I understand Terraform tries to list files during the plan command. Is there a way to list files after they have been generated from the same terraform code?
resource "terraform_data" "files" {
depends_on = [null_resource.generate_files]
# Input argument is reflected to output
input = [
for f in fileset(local.root_path, "*.txt") : f
]
}
output "text_one" {
value = terraform_data.files.output[0]
}
The output text_one
value gives:
The given key does not identify an element in this collection value: the collection has no elements.