Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

opentofu

БесплатноБез исполняемых скриптовНе проверен

OpenTofu is the open-source (MPL-2.0, Linux Foundation) fork of Terraform: it provisions cloud infrastructure from HCL files with the `tofu` command and reads…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

OpenTofu

Overview

OpenTofu (tofu) is a drop-in replacement for the Terraform CLI that stayed open source after HashiCorp moved Terraform to the BSL license. It reads the same .tf files and the same registry providers and modules. Migrating is mostly "run tofu instead of terraform". It also has features Terraform does not: client-side encryption of state and plan files, lifecycle { enabled = ... }, for_each on providers, and variables in backend and module source blocks. This skill covers install, project layout, state encryption, remote state, tests, migration and CI use. It was checked against OpenTofu 1.13.2.

Instructions

1. Install

brew install opentofu                      # macOS, Linux (Homebrew)
sudo snap install --classic opentofu       # Linux with snap
tofu version                               # expect: OpenTofu v1.13.x

Other options (deb/rpm repositories, Windows winget, a standalone installer script) are listed at https://opentofu.org/docs/intro/install/. If you use the standalone script, download it to a file, read it, and run it from the file; do not pipe it into a shell. The script verifies its downloads with cosign or GnuPG, so one of them must be installed. For a manual install, download the release zip and tofu_<version>_SHA256SUMS from the GitHub release page and run sha256sum -c before unzipping.

2. Write and run a configuration

# main.tf
terraform {
  required_version = ">= 1.8.0"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 6.0"
    }
  }
}

variable "project" {
  type    = string
  default = "billing-api"
}

variable "region" {
  type    = string
  default = "eu-west-1"
}

variable "environment" {
  type    = string
  default = "staging"
}

provider "aws" {
  region = var.region
}

locals {
  common_tags = {
    Project     = var.project
    Environment = var.environment
    ManagedBy   = "opentofu"
  }
}

module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "~> 6.0"

  name = "${var.project}-vpc"
  cidr = "10.0.0.0/16"

  azs             = ["${var.region}a", "${var.region}b", "${var.region}c"]
  private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
  public_subnets  = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]

  enable_nat_gateway = true
  single_nat_gateway = var.environment != "production" # one NAT outside production saves cost

  tags = local.common_tags
}
tofu init                      # download providers and modules, write .terraform.lock.hcl
tofu fmt -recursive            # canonical formatting
tofu validate                  # syntax and type check, no cloud calls
tofu plan -out=plan.tfplan     # preview and save the plan
tofu apply plan.tfplan         # apply exactly what was reviewed
tofu state list                # resources tracked in state
tofu destroy                   # destructive: tears everything down; review its plan first

Commit .terraform.lock.hcl; never commit .terraform/, *.tfstate or *.tfvars that hold secrets.

3. Encrypt state and plans

Encryption is configured in the terraform block and applies to local state, remote state and saved plans. A tested minimal setup with a passphrase (at least 16 characters):

terraform {
  encryption {
    key_provider "pbkdf2" "main" {
      passphrase = var.state_passphrase
    }
    method "aes_gcm" "main" {
      keys = key_provider.pbkdf2.main
    }
    state {
      method   = method.aes_gcm.main
      enforced = true # refuse to read or write unencrypted state
    }
    plan {
      method   = method.aes_gcm.main
      enforced = true
    }
  }
}

variable "state_passphrase" {
  type      = string
  sensitive = true
}
export TF_VAR_state_passphrase="correct-horse-battery-staple-9271"   # from your secret store, not from git
tofu init && tofu plan -out=plan.tfplan && tofu apply plan.tfplan

For production prefer a KMS key provider so there is no passphrase to leak. AWS example (key_spec is required; the other built-in providers are GCP KMS, Azure Key Vault and OpenBao):

key_provider "aws_kms" "prod" {
  kms_key_id = "alias/opentofu-state"
  key_spec   = "AES_256"
  region     = "eu-west-1"
}

Migrating an existing unencrypted state: first add a method "unencrypted" "legacy" {} and set fallback { method = method.unencrypted.legacy } inside the state block, with enforced = false. Run tofu apply once so the state is rewritten encrypted. Then remove the fallback and set enforced = true. Do not rename key providers or methods after data is encrypted, because their names are stored in the file; to change a key, put the old one in a fallback block. Losing the key means losing the state.

4. Remote state

terraform {
  backend "s3" {
    bucket       = "acme-tofu-state-eu-west-1"
    key          = "billing-api/staging/terraform.tfstate"
    region       = "eu-west-1"
    use_lockfile = true
Полный SKILL.md на GitHub

Установить opentofu в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл opentofu?

OpenTofu is the open-source (MPL-2.0, Linux Foundation) fork of Terraform: it provisions cloud infrastructure from HCL files with the `tofu` command and reads existing Terraform configurations, providers and state. Use when someone asks to "set up OpenTofu", "migrate from Terraform to OpenTofu", "encrypt Terraform state", "write a tofu module", "add tests to my infrastructure code", or "store state in S3 with locking".

Как установить скилл opentofu?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл opentofu запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить opentofu с