I ran into this issue today after beginning to use a new M1 mac. I had a single data resource using template_file
. Unfortunately, you are unable to run terraform init
even after removing any references to the the provider (I imagine this has to do with the data resource still existing in the state file).
I found a hacky work around. As previously stated, the provider has been deprecated for a year which preceded the release of the M1 chip. Do not keep using this provider if at possible and instead switch to using the templatefile
function.
My hack at a high level is to point Terraform to a dummy hashicorp/template
binary file. This hack will only help you run terraform init
so that you can migrate away from the provider. Otherwise, you will need to build the provider yourself locally.
The hack in question:
#!/usr/bin/env bash
set -x
# some variables used through out
provider_name="template"
provider_source_address="registry.terraform.io/hashicorp/${provider_name}"
provider_version="2.2.0"
all_providers_dir=$(mktemp -d)
rcfile=$(mktemp)
# making the dummy provider
dummy_provider_dir="${all_providers_dir}/${provider_source_address}/${provider_version}/darwin_arm64"
mkdir -p "${dummy_provider_dir}"
touch "${dummy_provider_dir}/terraform-provider-${provider_name}_v${provider_version}"
# making terraform.rc file to point to dummy provider
cat > "${rcfile}" <<EOF
provider_installation {
filesystem_mirror {
path = "${all_providers_dir}"
include = ["${provider_source_address}"]
}
direct {
exclude = ["${provider_source_address}"]
}
}
EOF
# running Terraform with dummy provider
TF_CLI_CONFIG_FILE="${rcfile}" terraform init
I then ran terraform state rm data.template_file.name
for all relevant offending resources.