* terraform/provider: import the SeaweedFS Terraform provider Import terraform-provider-seaweedfs by Luís Costa (MIT) as a nested Go module. It manages S3 buckets and their configuration (tags, CORS, lifecycle, versioning, policy, encryption, public access block, ownership controls, request payment, quota), IAM users, access keys, groups, roles, policies, attachments, OIDC providers and service accounts, and S3 Tables buckets, namespaces, tables, policies and maintenance configuration. The module path and the provider source address move to seaweedfs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: build and test in-tree Drop the standalone repo's release and git-hook instructions, credit the original author, and list the provider in the terraform layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform: vet and unit-test the provider in CI Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: keep configured JSON in state after apply Bucket, group, managed and S3 Tables policies stored the compacted JSON sent to the server, so a policy written as a heredoc or with file() failed apply with an inconsistent result. Keep the planned string, and keep configured table metadata while the server's copy is semantically equal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: read IAM policy documents without query unescaping SeaweedFS returns user, group and managed policy documents as raw JSON and role trust policies path-escaped. Query unescaping turned a "+" in a resource into a space and failed on a literal "%". Return valid JSON as is and path-unescape anything else. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: keep service account settings left out of the config description, expiration and status are optional and computed, so a change to another attribute planned them as unknown and Update sent empty values. SeaweedFS reads an empty Expiration as "never expires". Carry the prior state forward for unknown values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: use the root IAM path in the full example The user resource accepts only "/", so the example failed at user creation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: make the smoke test and local build portable Use the in-repo chart by default and check it before touching the cluster, bind the port-forward to 127.0.0.1 and fail when it does not start, build from the module directory, and point dev_overrides at the directory holding the binary. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: keep large JSON numbers exact when normalizing Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: compare single statements, empty Sid and scalar conditions canonically Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: reject unknown provider settings instead of using the environment Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: do not adopt a bucket owned by another identity Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: clear tags of an adopted bucket when the config sets none Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: report bucket configuration settings SeaweedFS did not store Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: treat empty and absent lists alike when comparing bucket configuration Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: refuse to adopt an existing IAM user unless a retried create made it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: keep omitted role settings so a trust policy change updates in place Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: resend a service account expiration only when it changes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: keep a configured expiration that names the same instant Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: stop retrying CreateAccessKey when a failed attempt left a key Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: add new group members before removing old ones Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: reject empty or padded OIDC client IDs, thumbprints and URL Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: keep an empty OIDC list as a known empty set Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: reject an empty namespace or name for a table policy Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: compare table metadata with the server's omitted required=false Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: do not replace a table when only metadata formatting differs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: keep a created S3 Tables object in state when its cleanup fails Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: reject an explicitly empty compaction strategy Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: document import IDs and the object lock versioning destroy case Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: stop on any uncertain CreateAccessKey failure and name the keys it left Only NoSuchEntity (user not visible yet) is retried. Any other failure, including cancellation and a failure on the last attempt, lists the user's keys once more and reports the new ones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: do not adopt an IAM user found after a failed CreateUser attempt A retry that hits EntityAlreadyExists cannot tell whether the failed attempt or another client created the user, so ask for an import. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: point BucketAlreadyExists on bucket create to terraform import SeaweedFS answers BucketAlreadyExists both for another identity's bucket and for the caller's own bucket that has an ACL, so the create cannot adopt it safely. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: treat omitted public access block flags as false when comparing Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: restore the BucketOwner-only note on the request payment resource Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: say the smoke test runs the version the chart deploys Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * terraform/provider: make the unknown endpoint test check the unknown-setting error Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
5.7 KiB
SeaweedFS on Terraform
Experimental. This Terraform support is an early scaffold under active development. Interfaces (variables, outputs, module layout) may change without notice, and not every tier is implemented yet. Not recommended for production without your own review and testing.
Self-contained Terraform/OpenTofu modules to deploy SeaweedFS on cloud VMs
running the weed binary directly under systemd. No Helm and no Kubernetes
required.
What works today is verified end-to-end against a real weed cluster (see
"Test it locally" below).
Layout
terraform/
modules/
core/ cloud-agnostic renderer (ZERO cloud resources): turns an
address map + config into per-node weed argv, systemd units,
config files, disk-mount + secret-fetch scripts, and cloud-init.
Both the cloud wrappers and the local harnesses consume `nodes`.
security/ cloud-agnostic CA + per-component mTLS certs (distinct CNs) +
JWT signing keys (tls/random providers). Emits a `core_security`
object ready for the core, plus PEMs for secret-store delivery.
aws/ thin AWS wrapper: reserves stable ENIs (fixed private IPs)
first, feeds them to core, creates instances + protected EBS
data disks + SG; with enable_security it generates certs/JWT,
stores them in SSM SecureString, grants an instance role, and
renders a boot fetch-secrets.sh. Keyed for_each throughout.
examples/
aws-ha-distributed/ 3 masters + 3 volumes (1/AZ) + 2 filers + 1 S3,
secure-by-default (mTLS via SSM-delivered certs)
aws-all-in-one/ single `weed server` instance via core directly
provider/ Terraform provider (Go) that manages S3 buckets and their
configuration, IAM and S3 Tables through a running cluster's
S3 and IAM APIs; see provider/README.md.
test/
local/ render a cluster with core and run it as real weed processes
on 127.0.0.1 (no cloud, no docker), then assert it works
local-secure/ generate certs/JWT with the security module, run a real
mTLS cluster, and assert it forms + enforces JWT auth
Design in one paragraph
The chart is the structural reference, not a dependency. A cloud-agnostic
core renders everything portable; thin per-cloud wrappers provision infra.
Addressing is an input to the core (wrapper reserves static IPs first), so
the wrapper -> core dependency is one-way with no apply-time cycle. Stateful
tiers (master/volume/filer) are keyed for_each maps, never count, so a
middle node can be replaced without reindexing its peers or reattaching the
wrong disk. Flag names are verified against the real weed binary
(notably: volume uses -mserver for the master list; gRPC is -port.grpc,
auto = http+10000; minFreeSpacePercent is a string).
Test it locally
Requires tofu (or terraform), jq, curl, and a weed binary. Renders a
3-master + volume + filer + S3 cluster from the core module and runs it as real
processes, asserting quorum, volume registration, and filer/S3 round-trips:
cd terraform/test/local
WEED=/path/to/weed ./run_local_cluster.sh
# => 7 passed, 0 failed
The harness uses a high port range (29333/28080/28888/28333) so it does not
collide with a SeaweedFS cluster already running on the machine, and aborts if a
required port is taken. KEEP=1 ./run_local_cluster.sh leaves the cluster up.
mTLS end-to-end
cd terraform/test/local-secure
WEED=/path/to/weed ./run_local_secure.sh
# => generates a CA + component certs + JWT, renders security.toml, runs a real
# mTLS cluster, asserts master/volume/filer form over mutual TLS and that the
# filer enforces JWT signing (unsigned writes get 401). 5 passed.
Plan-level tests (no cloud)
cd terraform/modules/core && tofu test
# => 11 passed: peers list, -mserver vs -master, metrics gating,
# security.toml conditions, all-in-one inheritance, ...
Validate the cloud wrappers
cd terraform/examples/aws-ha-distributed && tofu init && tofu validate
apply needs AWS credentials, a VPC, subnets, and an AMI with weed installed
(bake with Packer, or install at boot).
Status
Implemented and verified:
- Tiers: master / volume / filer / s3 / all-in-one rendered by the core.
- Disk mount: cloud-init runs a
mount-disks.shthat auto-discovers (or takes explicit candidate devices),blkid-guardsmkfs, mounts, and persists to/etc/fstabby UUID. The AWS wrapper wires the protected EBS disk to/data. - mTLS + JWT: the
securitymodule generates the CA + per-component certs (distinct CNs) + JWT keys; the AWS wrapper stores them in SSM SecureString, grants an instance role, and the core renders a boot fetch script so secrets stay OUT of user_data. Proven end-to-end bytest/local-secure.
Not yet implemented:
- sftp / admin / worker tiers (core does not render them yet).
- GCP/Azure wrappers, the data-plane provider, and the K8s-native module.
- CA in Vault PKI (currently TF-generated, so the CA key lives in state). KMS
decrypt in the IAM policy is scoped by
ViaServicebut usesResource="*"; tighten to the SSM CMK in production.
Gotchas
- This
weedbuild starts an Iceberg REST catalog on:8181by default; sets3.iceberg_port = 0to disable, or a port to relocate it. - Disk auto-discovery assumes a single attached data disk per node. For multiple
data disks, pass explicit
devicescandidates indisk_mounts.
Security note
tofu output/state can contain secrets. Generate secrets outside Terraform
(cloud secret manager / Vault) and fetch them at boot; never commit secret
material.