---
title: "Use OpenTofu for infrastructure as code · Agent Wranglers"
url: https://agentwranglers.se/playbook/stack/delivery-and-infrastructure/opentofu
updated: 2026-10-21
licence: "All rights reserved"
---

# Use OpenTofu for infrastructure as code

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers). Updated 2026-10-21.

- Level: Recommended
- Chapter: [Delivery and infrastructure](https://agentwranglers.se/playbook/stack/delivery-and-infrastructure)
- Rule: Describe all cloud resources in OpenTofu files kept in the repository, and apply them only from CI.
- Cost: Open source. MPL-2.0, free to run anywhere. Remote state storage in a cloud bucket is paid.
- How: OpenTofu is the open source fork of Terraform, hosted by the Linux Foundation under the MPL-2.0 licence. Its first stable release was 1.6.0 on 10 January 2024. That is under five years, but it continues the Terraform code that reached 1.0 in June 2021. Version 1.13.1 shipped on 1 October 2026. Terraform is the most used tool of its kind in the Stack Overflow Developer Survey 2026, at 18.3%, ahead of Ansible at 12.0%. OpenTofu reads the same HCL files and providers, so AI tools write it well. Keep state remote as [Keep state remote with locking and encryption](https://agentwranglers.se/playbook/infrastructure/infrastructure-as-code/remote-state) says. Choose something else when a team already runs Terraform under a commercial HashiCorp contract. Then keep it and pin the version.
- Check: `tofu plan` on the main branch shows zero changes. The `required_version` line pins OpenTofu to one minor version, such as `~> 1.13.0`.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### Terraform example

```hcl
terraform {
  required_version = "~> 1.13.0"
  required_providers {
    aws = { source = "hashicorp/aws", version = "~> 6.0" }
  }
}
```

### Shell example

```sh
tofu init -input=false
tofu plan -detailed-exitcode -out=plan.out
```

## Sources

- [OpenTofu](https://opentofu.org/)
- [OpenTofu 1.6.0 is generally available](https://opentofu.org/blog/opentofu-is-going-ga/)

## Related rules

- [Keep state remote with locking and encryption](https://agentwranglers.se/playbook/infrastructure/infrastructure-as-code/remote-state) in Infrastructure

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/stack/delivery-and-infrastructure/opentofu">Agent Wranglers software choices playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Use Docker and Docker Compose for containers](https://agentwranglers.se/playbook/stack/delivery-and-infrastructure/docker-and-compose)
- Next: [Avoid HashiCorp tools under the Business Source License for new work](https://agentwranglers.se/playbook/stack/delivery-and-infrastructure/avoid-busl-hashicorp)
- [Delivery and infrastructure](https://agentwranglers.se/playbook/stack/delivery-and-infrastructure)
