# Fix "Provider registry.terraform.io/hashicorp/template v2.2.0 does not have a package available for your current platform, darwin_arm64"

Yes. An agent replaces each template_file data source with the built-in templatefile() function and shows that the rendered text is the same.

[Run this on Rush](https://cloud.getrush.ai/run/fix-template-provider-darwin-arm64/terraform/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The `hashicorp/template` provider stopped at version 2.2.0, and that release has no build for Apple silicon. A configuration that still declares `data "template_file"` initialises on a Linux CI runner and on an Intel Mac, then fails `terraform init` on an M-series laptop with the message in the title. Nothing is wrong with the reader's machine. The provider is the problem, and Terraform has shipped its replacement since 0.12: the `templatefile(path, vars)` function, which renders the same template syntax with no provider at all.

deanwilson/tf_sns_email is a small module that shows the whole pattern. Its `main.tf` declares `data "template_file" "cloudformation_sns_stack"`, sets `template = file("${path.module}/templates/email-sns-stack.json.tpl")`, passes three `vars` (`display_name`, `email_address`, `protocol`), and feeds `data.template_file.cloudformation_sns_stack.rendered` to the `template_body` of an `aws_cloudformation_stack`. The agent deletes the data block and writes `template_body = templatefile("${path.module}/templates/email-sns-stack.json.tpl", { ... })` with the same three keys. `versions.tf` in that module holds only `required_version = ">= 0.12"` and no `required_providers` block, so there is no provider entry to remove, and the version floor already covers `templatefile`.

The agent then proves the edit changed nothing. In its sandbox it downloads a Terraform binary, copies the template into a scratch configuration that renders it both ways with the same inputs, and compares the two strings for equality. It also runs `terraform providers lock -platform=darwin_arm64` before and after: before the change that command fails naming `hashicorp/template`, and after it the provider is no longer listed for the configuration. This matters because a Linux sandbox cannot hit the original error with `terraform init`; asking Terraform to lock providers for the Mac platform is how the failure is reproduced off a Mac.

Two things in this module are not fixed by the swap, and the agent reports them instead of hiding them. First, the template writes `"${display_name}"` straight into JSON, so a display name containing a double quote produces an invalid CloudFormation body under either approach; wrapping values with `jsonencode` is the real fix, but it changes the rendered text and belongs in its own pull request. Second, Terraform state still records the old data source. Until one `terraform apply` has run from a machine that can install the provider, `terraform init` on Apple silicon keeps asking for it, because Terraform installs the providers that state requires as well as the ones the configuration does. The agent also lists what it noticed while reading: `variables.tf` declares an `owner` variable described as setting a tag, and `main.tf` never reads it.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "terraform init fails on Apple silicon with \"Provider registry.terraform.io/hashicorp/template v2.2.0 does not have a package available for your current platform, darwin_arm64\". Find every data \"template_file\" block in this repository, including in modules it vendors. Replace each with the built-in templatefile() function: the same template path, the same variables, and every reference to data.template_file.<name>.rendered rewritten to the new expression or to a local that holds it. If a template_file block uses an inline template string instead of file(), move the string to a .tftpl file first. Remove the template provider from required_providers and from any provider block if it is declared, and leave every other provider constraint alone. Do not change what any template renders: no jsonencode, no reformatting of the template files. Prove the result. Install Terraform, then (1) for each template, render it with template_file and with templatefile() using the same sample inputs in a scratch directory and show that the two strings are equal, (2) run terraform providers lock -platform=darwin_arm64 -platform=linux_amd64 before and after the change and include both outputs, (3) run terraform fmt -check and terraform validate. Do not run terraform plan or apply against any real backend and do not use cloud credentials. In the pull request description, list each replaced block, the two proofs, anything in a template that would break for unusual input (for example a value interpolated into JSON without escaping), and the one step the owner still has to do: apply once from a machine that can install the old provider, or remove the data source from state, so that state stops requiring it.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

A pull request that touches the `.tf` files where a `template_file` block lived and, when the provider was declared, the file holding `required_providers`. For a module shaped like tf_sns_email that is one file: the data block is gone and `template_body` calls `templatefile()` directly. The template file itself is untouched, which a reviewer can confirm from the file list before reading a line.

The description carries the evidence in the order a reviewer needs it. The equality check for each template comes first, since it is the claim that the stack will not be replaced. The two `terraform providers lock` outputs come next and show the failure for `darwin_arm64` disappearing. Last is the state note: the next apply drops the data source from state, and until then a colleague on Apple silicon still cannot initialise against the shared backend. A reviewer who merges without reading that note will hear about it from the first Mac user.

Anything the agent declined to change is listed with its reason. Unescaped interpolation into JSON or shell, a variable nothing reads, a README command that an older Terraform accepted: each is a line in the description, not a silent edit, so the diff stays a pure provider removal.

## Run it on every issue labelled apple-silicon

This error is reported by a person, usually the first teammate with a new laptop, so an issue is the natural start. Add an automation to the Project that holds the infrastructure repository, give it the prompt above, and add a `github` trigger on `issues.labeled` with `labels` set to the label your team uses. When a member labels an issue, Rush starts a run and puts the issue after the prompt as event text. The prompt stays the only instruction; the issue body fills in nothing.

Only an issue from an owner, member or collaborator fires the trigger, which suits an internal infrastructure repository. For many module repositories, skip the trigger and send the request once per repository from your own script, each with its own `request_id` that is a fresh UUID.

## Why run it on Rush?

The proof needs two platforms and no Mac. Locking providers for `darwin_arm64` from a Linux sandbox shows the failure and its absence without anyone lending a laptop, and the scratch render that compares both outputs runs with no cloud account. Each command and its output stays in the session record, so the pull request's claims can be checked against what was actually executed.

It is also work that waits. The configuration still applies from CI, so the fix sits behind a workaround such as a Rosetta build of Terraform until someone has an afternoon. A run does the replacement, the two proofs and the write-up in one pass and pushes a branch; the infrastructure owner spends their time on the review and on the one apply that clears state.

## Frequently asked questions

### Is there an arm64 build of the template provider I can install instead?

Not from HashiCorp. Version 2.2.0 is the provider's last release and it has no `darwin_arm64` package, which is exactly what the error says. Running an Intel build of Terraform under Rosetta works as a stopgap, and replacing the data source removes the need for it.

### Will switching to templatefile() make Terraform replace my resources?

Not when the rendered string is identical, and for the same template and variables it is. The run checks that directly by rendering both ways and comparing. Your own `terraform plan` after merging is the final check, and it should show no change to the attribute that consumed the template.

### I merged the change and init still fails on my Mac. Why?

State still lists the old data source, and `terraform init` installs providers that state requires. Run one apply from CI or an Intel machine so the data source is dropped from state, then initialise again on the Mac.

### What about template_file blocks with an inline template?

`templatefile()` reads a file, so the agent moves the inline string into a `.tftpl` file beside the module and calls it from there. For a one-line template it uses a plain string expression with interpolation instead, and says which it chose.

### Does the same fix apply to template_cloudinit_config?

That data source comes from the same archived provider and fails the same way. Its replacement is the `cloudinit_config` data source from the `hashicorp/cloudinit` provider, which does publish Apple silicon builds. The agent makes that swap when it finds one and proves it with the same lock command.

## More Terraform jobs

- [Review Terraform Pull Requests for an AWS Module](https://getrush.ai/run/review-terraform-changes/terraform/)
- [Run a Security Audit on a Terraform Module](https://getrush.ai/run/security-audit/terraform/)
- [Upgrade Terraform Providers in a Terraform Module](https://getrush.ai/run/upgrade-terraform-providers/terraform/)

## More jobs like this: Fix a bug from an alert

- [Fix "AttributeError: module 'tensorflow' has no attribute 'Session'" in TensorFlow 2](https://getrush.ai/run/fix-tensorflow-session-attribute-error/tensorflow/)
- [Fix ClientClosedError: The client is closed in a Node.js Redis App](https://getrush.ai/run/fix-the-client-is-closed-error/node-redis/)
- [Fix "DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead" in a Python Library](https://getrush.ai/run/fix-the-warn-method-is-deprecated-use-warning-instead/logging/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
