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
When changing file permission the file is only created after second time apply #146
Comments
I am seeing something similar except it's when the contents of the file change. I'm having trouble reproducing it on a small scale, but in my case the local_file resource is buried a few modules deep. I do notice when I run
If I try If it matters, my filenames are I predict the I've tested with terraform 1.3.0, 1.3.1 and 1.3.2 as well as local module versions 2.2.2 and 2.2.3. Early in my testing I did try |
Looks like terraform does not manage file permissions. The file_permissions attribute is used when terraform creates the file, but it does not attempt to manage those permissions once the file exists. That is, if terraform creates the file with "0644" and you chmod 777 the file outside of terraform, terraform will not notice the change and fix the permissions on future runs of "terraform apply". Similarly, "terraform refresh" also does not update state with the actual file permissions. terraform 1.5.7. |
I don't think this problem is permissions-related. The problem is that this is not a reasonable situation to use The Therefore I expect Terraform is effectively performing the following sequence of actions:
This is one of the hazards of using Terraform to manage files, since Terraform is really designed for managing objects via network APIs. Avoiding the use of Another option is to make sure each new version of the file has a different filename, in which case Terraform will be able to create the new one without overwriting the old one and can then delete the old one safely. |
Terraform CLI and Provider Versions
Terraform v1.3.2
on linux_amd64
Terraform Configuration
Expected Behavior
Expected a file to be generated after running one time the command terraform apply when changing the file permission of an existing file. Seems it deletes the old file but a new file is not being created. After running terraform apply for second I see the new file is being created. No error is thrown after the first time running the apply method.
Actual Behavior
After 1 time terraform apply the file gets removed and no new file is created.
Steps to Reproduce
terraform apply
to create a new fileHow much impact is this issue causing?
Low
Logs
No response
Additional Information
Think this bug is only when using the lifecycle create_before_destroy.
Code of Conduct
The text was updated successfully, but these errors were encountered: