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

Add modification timestamp or other way to reliably indicate change. #70

Open
Patricol opened this issue May 10, 2022 · 1 comment
Open

Comments

@Patricol
Copy link

Patricol commented May 10, 2022

Hello! Thanks for the provider.

Currently, id is deterministic, and I don't see any other attributes that can be used to reliably trigger, for example, a null_resource whenever remote_file is applied.

A more specific example:

resource "remote_file" "iscsi" {
  content = local.content
  path = local.path
}

resource "null_resource" "restoreconfig" {
  triggers = {
    content = sha256(remote_file.iscsi.content)
    file = remote_file.iscsi.id
  }
  provisioner "remote-exec" {
    inline = ["targetcli restoreconfig savefile=${remote_file.iscsi.path} clear_existing=True"]
  }
}

If something else changes the contents of the file; applying again will change the file back, but will not rerun restoreconfig. remote_file doesn't currently have any documented attributes that can solve this problem.

@tenstad
Copy link
Owner

tenstad commented May 10, 2022

Hi! We could add a last_modified timestamp to the remote_file resource (at least the remote_file data source). That would solve your problem, right? But I wonder why something else would change the file. Is terraform not considered the owner and sole editor of the file?

Another thought, could you use a remote_file data source to read the current file content, and trigger the provisioner only if the current and desired content differ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants