title: Terraform download local file from remote URL on apply and delete file on destroy
body: <p>I need to download a lambda archive file from an URL before actual lambda resource is created and this file needs to be deleted when I run terraform destroy. Basically a local file resource created from a remote URL. I have it currently done using a <code>null_resource</code> and <code>local-exec</code> provisioner like below. But this doesn't delete the file when i run terraform destroy. Is there a better way?</p>
  <pre><code>resource &quot;null_resource&quot; &quot;lambda_jar&quot; {
    triggers = {
      on_version_change = &quot;${var.lambda_archive_version}&quot;
    }
  
    provisioner &quot;local-exec&quot; {
      command = &quot;curl -o lambda.jar ${var.server_url}/${var.lambda_archive_version}.jar&quot;
    }
  }
  </code></pre>