-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate checkout directories for each instance in module "for_each" #26564
Comments
Hi @ocervell! Thanks for suggesting this. I can see that the current behavior is inconvenient for modules are built to work with With that said, I don't think a separate checkout directory for each instance is a viable solution to the problem, because module installation happens during This problem statement reminded me of an old proposal I made, in #21308. I had a different problem statement in mind at the time I created that one, but it's aiming at approximately the same place of giving each module instance a dynamically-assigned directory to use for temporary files in situations where temporary files are unavoidable. If we were to implement something like that today, I expect we'd arrange for What do you think of that as an alternative way to address the problem you raised here? |
Sounds good to me, support for temp directories should solve this use case if implemented right indeed. What I am doing with
Now one thing that worries me is when data |
Hi @ocervell, I think the requirement for your situation would be to make sure that the With that said, as I mentioned in the writeup in #21308 the The |
Current Terraform Version
Use-cases
Currently, the folder path where the module code is checked out is the same for all iterations of the
for_each
loop:.terraform/modules/<MODULE_NAME>
.This causes problems with configs where a local directory is being used to i.e create archive files, because each instance of the
for_each
loop will share that local directory. If we're dynamically adding files to this directory they might conflict with each other (and overwrite the existing file).This will apply to any use case where we add / change files from a path in the module checkout folder.
Attempted Solutions
For the use case discussed above, I tried creating a new temp folder for each instance created but this is incompatible with
archive_file
resource that will fail on the next read if the temp folder is missing.Proposal
This issue would be alleviated if we had an option to specify separate checkout directories for each instance of the module.
The text was updated successfully, but these errors were encountered: