You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Many authors that write blog posts, books, tutorials, and training courses about Terraform use the "local_provider" as a fast simple way of helping students start to experiment with Terraform, configuration files, etc. (Based on the Hashicorp documentation some warning is provided that suggests that local files are difficult to work with because of so many variations across operating systems, etc. )
$ terraform version
Terraform v1.0.7
on linux_amd64
Expected Behavior
terraform refresh should detect that the file permissions drifted from desired state
Actual Behavior
terraform refresh has no affect; specifically, it does not update the terraform.tfstate file to indicate the actual/real file permissions of the local file. Therefore, using terraform plan | apply (when drift has occurred) has no effect.
Terraform Configuration Files
resource"local_file""pet" {
filename="pets.txt"content="I love pets!"file_permission="0600"
}
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
$ terraform init
$ terraform apply
---- Showing terraform created pets.txt with correct filename, permissions, etc
$ ls -l
total 24
-rw-r--r-- 1 Scott staff 143B Sep 18 10:07 local.tf
-rw------- 1 Scott staff 12B Sep 18 11:47 pets.txt
-rw-r--r-- 1 Scott staff 828B Sep 18 11:47 terraform.tfstate
--- Introducing Drift from desired state documented in local.tf
$ chmod 666 pets.txt
--- Showing drift introduced
$ ls -l
total 24
-rw-r--r-- 1 Scott staff 143B Sep 18 10:07 local.tf
-rw-rw-rw- 1 Scott staff 12B Sep 18 11:47 pets.txt
-rw-r--r-- 1 Scott staff 828B Sep 18 11:47 terraform.tfstate
--- Executing terraform refresh to update the terraform.tfstate
$ terraform apply
local_file.pet: Refreshing state... [id=7e4db4fbfdbb108bdd04692602bae3e9bd1e1b68]
No changes. Your infrastructure matches the configuration.
Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
Affected Resource(s)
local file
Important Factoids
No special factoids
References
None
The text was updated successfully, but these errors were encountered:
ScottFred
changed the title
terraform refresh does not detect changes to file permissions, ownershipterraform refresh does not detect changes to file permissions
Sep 18, 2021
ScottFred
changed the title
terraform refresh does not detect changes to file permissionsterraform refresh for local_file does not detect changes to file permissions
Sep 18, 2021
Many authors that write blog posts, books, tutorials, and training courses about Terraform use the "local_provider" as a fast simple way of helping students start to experiment with Terraform, configuration files, etc. (Based on the Hashicorp documentation some warning is provided that suggests that local files are difficult to work with because of so many variations across operating systems, etc. )
$ terraform version
Terraform v1.0.7
on linux_amd64
Expected Behavior
terraform refresh
should detect that the file permissions drifted from desired stateActual Behavior
terraform refresh
has no affect; specifically, it does not update theterraform.tfstate
file to indicate the actual/real file permissions of the local file. Therefore, usingterraform plan | apply
(when drift has occurred) has no effect.Terraform Configuration Files
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
$ terraform init
$ terraform apply
---- Showing terraform created pets.txt with correct filename, permissions, etc
$ ls -l
total 24
-rw-r--r-- 1 Scott staff 143B Sep 18 10:07 local.tf
-rw------- 1 Scott staff 12B Sep 18 11:47 pets.txt
-rw-r--r-- 1 Scott staff 828B Sep 18 11:47 terraform.tfstate
--- Introducing Drift from desired state documented in local.tf
$ chmod 666 pets.txt
--- Showing drift introduced
$ ls -l
total 24
-rw-r--r-- 1 Scott staff 143B Sep 18 10:07 local.tf
-rw-rw-rw- 1 Scott staff 12B Sep 18 11:47 pets.txt
-rw-r--r-- 1 Scott staff 828B Sep 18 11:47 terraform.tfstate
--- Executing
terraform refresh
to update the terraform.tfstate$ terraform refresh
local_file.pet: Refreshing state... [id=7e4db4fbfdbb108bdd04692602bae3e9bd1e1b68]
--- Showing that the terraform.tfstate was not updated
$ cat terraform.tfstate
--- Showing
terraform apply
has no effectAffected Resource(s)
local file
Important Factoids
No special factoids
References
None
The text was updated successfully, but these errors were encountered: