Skip to content
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

local_file resource crashes when replacing file with empty content #18316

Closed
ned1313 opened this issue Jun 22, 2018 · 2 comments
Closed

local_file resource crashes when replacing file with empty content #18316

ned1313 opened this issue Jun 22, 2018 · 2 comments

Comments

@ned1313
Copy link
Contributor

ned1313 commented Jun 22, 2018

Terraform Version

Terraform v0.11.7
+ provider.local v1.1.0

Terraform Configuration Files

##############################################
# Function: chomp
##############################################
##############################################
# Variables
##############################################
variable "chomp" {
  default = "A string with newlines \n\n\n\n\n"
}

##############################################
# Resources
##############################################
resource "local_file" "chomp_file" {
  content  = "${chomp(var.chomp)}"
  filename = "output.txt"
}

##############################################
# Outputs
##############################################
output "chomp_output" {
  value = "${chomp(var.chomp)}"
}

Debug Output

Crash Output

Error: Error applying plan:

1 error(s) occurred:

  • local_file.chomp_file: local_file.chomp_file: diffs didn't match during apply. This is a bug with Terraform and should be reported as a GitHub Issue.

Please include the following information in your report:

Terraform Version: 0.11.7
Resource ID: local_file.chomp_file
Mismatch reason: attribute mismatch: content
Diff One (usually from plan): *terraform.InstanceDiff{mu:sync.Mutex{state:0, sema:0x0}, Attributes:map[string]*terraform.ResourceAttrDiff{"filename":*terraform.ResourceAttrDiff{Old:"output.txt", New:"output.txt", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "content":*terraform.ResourceAttrDiff{Old:"String with two lines\n Second line with newline ", New:"", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Sensitive:false, Type:0x0}}, Destroy:false, DestroyDeposed:false, DestroyTainted:false, Meta:map[string]interface {}(nil)}
Diff Two (usually from apply): *terraform.InstanceDiff{mu:sync.Mutex{state:0, sema:0x0}, Attributes:map[string]*terraform.ResourceAttrDiff{"filename":*terraform.ResourceAttrDiff{Old:"", New:"output.txt", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Sensitive:false, Type:0x0}}, Destroy:false, DestroyDeposed:false, DestroyTainted:false, Meta:map[string]interface {}(nil)}

Expected Behavior

The local file should have been overwritten with new content, in this case an empty string was submitted, so no content in the file.

Actual Behavior

The file was removed.

Steps to Reproduce

terraform init
terraform apply -var "chomp=String with one newline \n" -auto-approve
terraform apply -var "chomp=" -auto-approve

Additional Context

This only seems to happen when there is content in the file and then I am submitting an empty string as the new content.

References

@ghost
Copy link

ghost commented Jun 22, 2018

This issue has been automatically migrated to hashicorp/terraform-provider-local#15 because it looks like an issue with that provider. If you believe this is not an issue with the provider, please reply to hashicorp/terraform-provider-local#15.

@ghost ghost closed this as completed Jun 22, 2018
@ghost
Copy link

ghost commented Apr 3, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 3, 2020
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants