Hello, welcome to the forum both!
Before addressing the error, I just wanted to note something important about the nature of local_file
and Terraform Cloud. The Terraform Cloud run environment is ephemeral, and the filesystem that you’re writing a file to is destroyed and recreated in a subsequent run. You can see this by leaving the resource block and running subsequent plans:
Depending on what you’re trying to do, you may not want to use this resource because of the nature of the remote run environment.
I have indeed recreated the error you found, though, and have determined it’s something due to the nature of provider schemas needing to be re-fetched for the remote run environment even as the local
provider is no longer declared in the configuration (you removed it) and the ‘remote’ object (the literal file) has been deleted as expected.
If you really would like to continue using local_file
with the ephemeral filesystem point I mentioned, a workaround for this is to declare the local
provider explicitly for the runtime by adding something like this:
terraform {
required_providers {
local = {
version = "~> 2.1"
}
}
Then the provider will be initialized and when you remove the resource block the plan will look like the following, which is expected:
Hope that helps!