cdk

module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: MIT

README

john/cdk

A small, strongly typed Go kit for infrastructure as code, in the style of the AWS CDK. Programs build an App of Stacks of Resources; Synth writes plain OpenTofu configuration to .yawn/. OpenTofu still does all planning, applying and state.

  • Library, not a service. Repositories depend on this module and own their programs. john/arch runs them in CD.
  • .yawn/ is built in CI only. It is gitignored and never committed.
  • Standard library only. No third-party Go dependencies.
  • Deterministic. The same program always writes the same bytes.
  • Nothing left to defaults. Constructs write every setting explicitly.

Usage guidance lives in the wiki. This repository does not maintain standalone example applications; consumers own their stack programs.

Packages

Package Provides
core App, Stack, Resource, Provider, Synth, manifest.json, enforced state encryption, S3Backend, attached data documents
forgejo NewRepository, Protect, Provider (pinned svalabs/forgejo 1.7.0), UnreadSettings
proxmox Proxmox VE LXC containers (bpg/proxmox 0.122.0): import or create, destroy refused, Container.Fleet() identity
fleet Which Proxmox container runs which service (fleet.json), identity checks and drift reports for push deploys
workflow Native xyOps workflows: NewXyopsWorkflow (validated graph) and NewPipeline (plan → changes? → approval → deploy, run queue) (design)
oidc Verifies Forgejo Actions ID tokens (RS256, JWKS, claim policy, replay guard)
ci Generated Forgejo workflows from yawn.json, the task runner, and xyOps requests (guide)
cmd/yawn run, tasks, ci, request, digest, version, providers, oidc-verify, fleet-check, fleet-diff, plan-guard, app-verify, bootstrap

yawn release binaries (linux amd64/arm64, static) and their SHA256SUMS are attached to every release from 0.3.0-dev.21; generated workflows install them by checksum.

Design: deploy control plane, also published to the repository wiki on each release.

.yawn/ layout

.yawn/
  manifest.json            # typed, data-only summary (stacks, providers, resources, imports, notes)
  <stack>/main.tf.json     # the stack's OpenTofu configuration
  <stack>/encryption.tf    # enforced client-side encryption of state and plans
  <stack>/.terraform.lock.hcl  # provider hashes from the release pins
  fleet.json               # optional attached document: the declared fleet

manifest.json is data only, so a consumer such as john/arch can read it without running repository code. Its manifest_version is 1; consumers must refuse versions they do not understand.

Safety rules

  • Repositories are never deleted. prevent_destroy is set, and a forced destroy archives the repository instead.
  • No hidden defaults. Every writable provider attribute is either written or listed as creation-only. A test compares the constructs against the provider's schema, so a provider upgrade that adds a setting fails the build until the construct handles it.
  • Mandatory choices. Visibility must be chosen, and a protected branch must have at least one required check.
  • Exact provider pins. Exact versions, HTTPS release URLs, and SHA-256 plus OpenTofu h1 hashes. yawn providers checks both hashes, and the generated lock file makes OpenTofu check them again.
  • No secrets in output or state. Credentials come from the environment (FORGEJO_API_TOKEN, AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY, TF_VAR_*). Literal values for token, password or secret settings are refused, and the state passphrase must be an ephemeral variable so it never reaches a plan.
  • Unread settings are explicit. svalabs/forgejo does not read some repository settings back, so UI changes to them are invisible to plans; forgejo.UnreadSettings lists them for a separate drift check.
  • Atomic synth. A failed synth leaves the previous .yawn/ untouched.

Development

Go 1.27.4 and OpenTofu 1.13.9 are pinned in .forgejo/scripts/tools.py. .forgejo/scripts/check.sh TOOLS runs gofmt, module verification, vet, tests (including synthesis, schema and runtime coverage), and govulncheck. Consumer repositories validate their actual synthesized stacks with OpenTofu; this repository no longer runs example-based provider integration validation. Update golden files with go test ./core -update and review the diff.

History

v0.2.0-dev.1 targeted Gitea through a fork of its provider and Gitea's state registry. Forgejo has neither, so 0.3.0 moves to svalabs/forgejo and S3 state; the gitea package is removed.

Up to v0.1.0-dev.1 this repository held HCL modules (Caddy edge, SSO, oauth2-proxy, Peekaping status sites). They had no consumers and are retired from main; the tag keeps them.

Releases

Versioned with john/release: change VERSION and CHANGELOG.md in a PR, and merging tags the commit. Consumers pin a tag in go.mod.

Directories

Path Synopsis
Package apps declares application deploy slots: which repository may deploy which application, to which target, with which secrets.
Package apps declares application deploy slots: which repository may deploy which application, to which target, with which secrets.
Package ci generates a repository's Forgejo Actions workflows from one small declaration, yawn.json, and runs its tasks the same way locally and in CI.
Package ci generates a repository's Forgejo Actions workflows from one small declaration, yawn.json, and runs its tasks the same way locally and in CI.
cmd
yawn command
Command yawn works with synthesized .yawn/ output and the deploy control plane described in the design doc (wiki/design/deploy-control-plane.md).
Command yawn works with synthesized .yawn/ output and the deploy control plane described in the design doc (wiki/design/deploy-control-plane.md).
Package core is the construct model of the yawn kit.
Package core is the construct model of the yawn kit.
Package deploy implements the credential-scoped, always-waiting release client.
Package deploy implements the credential-scoped, always-waiting release client.
Package fleet declares, in code, which Proxmox container runs which service, so a push deploy job can prove it is touching the right container and a nightly check can catch the fleet drifting away from the code.
Package fleet declares, in code, which Proxmox container runs which service, so a push deploy job can prove it is touching the right container and a nightly check can catch the fleet drifting away from the code.
Package forgejo provides constructs for Forgejo repositories and branch protection, synthesized for the community OpenTofu provider svalabs/forgejo (registry.opentofu.org/svalabs/forgejo).
Package forgejo provides constructs for Forgejo repositories and branch protection, synthesized for the community OpenTofu provider svalabs/forgejo (registry.opentofu.org/svalabs/forgejo).
internal
install
Package install puts pinned provider zips into an OpenTofu filesystem mirror.
Package install puts pinned provider zips into an OpenTofu filesystem mirror.
Package oidc verifies Forgejo Actions ID tokens so an xyOps deploy job can trust "this is john/ops, push to main, run N, commit X" without CI holding any xyOps credential.
Package oidc verifies Forgejo Actions ID tokens so an xyOps deploy job can trust "this is john/ops, push to main, run N, commit X" without CI holding any xyOps credential.
Package pipeline validates portable pipeline declarations and binds one authenticated entry to reviewed platform workers.
Package pipeline validates portable pipeline declarations and binds one authenticated entry to reviewed platform workers.
Package proxmox declares Proxmox VE LXC containers with the bpg/proxmox OpenTofu provider.
Package proxmox declares Proxmox VE LXC containers with the bpg/proxmox OpenTofu provider.
Package route declares service-owned LAN routes under a shared wildcard TLS site.
Package route declares service-owned LAN routes under a shared wildcard TLS site.
Package workflow builds native xyOps workflows: a validated graph (NewXyopsWorkflow) and the plan -> changes? -> approval -> deploy pipeline (NewPipeline).
Package workflow builds native xyOps workflows: a validated graph (NewXyopsWorkflow) and the plan -> changes? -> approval -> deploy pipeline (NewPipeline).
Package workload resolves a service-owned declarative release against platform-owned capabilities.
Package workload resolves a service-owned declarative release against platform-owned capabilities.
Package xyops declares xyOps objects (events and secrets) with john/tofu-provider-xyops, a fork of the community provider published as registry.yawn.dev/john/xyops from Forgejo releases.
Package xyops declares xyOps objects (events and secrets) with john/tofu-provider-xyops, a fork of the community provider published as registry.yawn.dev/john/xyops from Forgejo releases.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL