iac/tofu/s3.tofu
Sergei Poljanski 796331815d
All checks were successful
nixos / nixos (push) Successful in 34s
tofu: rename from terraform, state in its own bucket, Loki buckets
The infrastructure is applied with OpenTofu; name it so. terraform/
becomes tofu/, the files end in .tofu (OpenTofu 1.8+ prefers them), the
local variables file is secrets.auto.tfvars, and both servers carry
managed_by=opentofu (an in-place label change).

The state moved to new buckets asxpio-tofu-main/-repl, key
tofu/state/tofu.tfstate, with `tofu init -migrate-state`; a plan against
it shows no changes. The old asxpio-terraform-* buckets stay, renamed
in the config with moved blocks, until the new state has been used for
a while.

asxpio-loki-main, created by hand, is adopted with an import block, and
a new asxpio-loki-repl in fsn1 receives it in the daily replica, which
now also copies the new state bucket instead of the old one.

What keeps the Terraform name is OpenTofu's own: the `terraform {}`
block and .terraform.lock.hcl.

Assisted-by: Claude:opus-5-5
2026-11-17 09:42:53 +04:00

67 lines
1.6 KiB
HCL

# OpenTofu state (backend in providers.tofu), replicated hel1 -> fsn1
resource "minio_s3_bucket" "state_main" {
provider = minio.hel1
bucket = "asxpio-tofu-main"
acl = "private"
}
resource "minio_s3_bucket" "state_repl" {
provider = minio.fsn1
bucket = "asxpio-tofu-repl"
acl = "private"
}
# Where the state lived until 2026-11-17 (named after Terraform). Kept
# until the migrated state has been used for a while, then emptied and
# removed.
moved {
from = minio_s3_bucket.terraform_main
to = minio_s3_bucket.legacy_state_main
}
moved {
from = minio_s3_bucket.terraform_repl
to = minio_s3_bucket.legacy_state_repl
}
resource "minio_s3_bucket" "legacy_state_main" {
provider = minio.hel1
bucket = "asxpio-terraform-main"
acl = "private"
}
resource "minio_s3_bucket" "legacy_state_repl" {
provider = minio.fsn1
bucket = "asxpio-terraform-repl"
acl = "private"
}
resource "minio_s3_bucket" "backups_main" {
provider = minio.hel1
bucket = "asxpio-backups-main"
acl = "private"
}
resource "minio_s3_bucket" "backups_repl" {
provider = minio.fsn1
bucket = "asxpio-backups-repl"
acl = "private"
}
# Loki's chunks (asxpio-ops, services.loki). Created by hand on
# 2026-11-14, adopted here on 2026-11-17.
import {
to = minio_s3_bucket.loki_main
id = "asxpio-loki-main"
}
resource "minio_s3_bucket" "loki_main" {
provider = minio.hel1
bucket = "asxpio-loki-main"
acl = "private"
}
resource "minio_s3_bucket" "loki_repl" {
provider = minio.fsn1
bucket = "asxpio-loki-repl"
acl = "private"
}