Blog · 2026-11-18 · Gardience Engineering · How we test

Spacelift and Gardience: servers that patch and harden themselves from first boot

Spacelift runs your OpenTofu and Terraform; Gardience keeps the Windows and Linux machines those stacks build patched, hardened, and audited. How to use the Gardience provider in a Spacelift stack, where the key goes, and what each tool catches.

STIG automation

Spacelift is good at the part of infrastructure that lives in code: it plans and applies your OpenTofu and Terraform, enforces policy on every run, and catches drift in your cloud resources. What it does not do is look inside the machines a stack builds. Nobody patches them, checks their STIG baseline, or notices when someone changes a setting by hand at 2 AM.

That is the job Gardience does. And because Gardience ships a provider for OpenTofu and Terraform, it fits inside a Spacelift stack with nothing extra installed in Spacelift.

What the two tools each catch

#
SpaceliftGardience
Builds and changes cloud resourcesYesNo
Drift in cloud resources (security groups, instance types, tags)Yes, with drift detectionNo
Patches Windows and Linux inside each machineNoYes, on rings with change windows
Drift inside the machine (settings, services, baseline checks)NoYes
DISA STIG and CIS-aligned baselines, CMMC Level 2 evidenceNoYes
A second person approves every change to machinesPolicy on runsEvery change, with a tamper-evident audit log

Used together, a stack builds a server and Gardience owns everything that happens on it after first boot.

How it works in a stack

#

The Gardience provider is public on both the Terraform and OpenTofu registries as gardience/gardience. In a stack it does four things:

  1. Opens an enrollment, which gives each new machine a first-boot script for user_data.
  2. Puts new machines in a group, so join rules can apply your baseline the moment they connect.
  3. Waits until each machine has actually joined, so the run fails loudly if one never does.
  4. Removes the machine from the fleet when the stack destroys it, with a 30-day safety hold on its key.

The address and API key go in a Spacelift context (Spacelift's shared settings for stacks), with the key marked secret, so nothing sensitive sits in your repository. The provider block stays empty because it reads GARDIENCE_URL and GARDIENCE_API_KEY from the environment:

terraform {
  required_providers {
    gardience = { source = "gardience/gardience" }
  }
}

provider "gardience" {}

resource "gardience_enrollment" "web" {
  label  = "web tier (spacelift)"
  hours  = 2160
  groups = ["web"]
}

The full setup, including private certificate authorities and attaching the context automatically by label, is in the Spacelift guide.

Windows too, without WinRM

#

Most configuration tools treat Windows as an afterthought. Gardience's agent connects out to your Gardience server, so a Windows Server a stack builds needs no open WinRM port and no stored domain password to be patched, hardened to a STIG baseline, or given an Ansible playbook. On AWS, the first-boot script just goes inside <powershell> tags in user_data.

What the key can and cannot do

#

The provider uses a configure API key. It manages configuration only and cannot run anything on machines already in the fleet. Schedules created with it start turned off until an admin looks at them, so a leaked key alone cannot make the fleet run something. Everything it does lands in the Gardience audit log under the key's owner.

Questions

#

Does Gardience work with Spacelift?

#

Yes. Spacelift runs OpenTofu and Terraform, and the Gardience provider is public on both registries, so any Spacelift stack can use it with no extra setup in Spacelift.

Does Spacelift patch servers?

#

No. Spacelift manages infrastructure as code and catches drift in cloud resources. Patching and hardening inside each Windows and Linux machine is what Gardience adds.

Where should the Gardience API key go in Spacelift?

#

In a Spacelift context, as an environment variable marked secret, attached to the stacks that build machines.

Do Spacelift's workers need to reach Gardience?

#

Yes, over HTTPS. Use Spacelift's private workers if your Gardience server is only reachable inside your network.

See the Spacelift guide or start the free 90-day trial on up to 25 machines.

Try Gardience on your own machines

One supported console for Windows and Linux on open-source Salt: patching, a scored STIG/CIS-aligned baseline, drift repair, event-driven automation, two-person approval and a tamper-evident audit log. Flat yearly pricing, not per node.

Free 90-day trial (25 nodes)See it work Compare

Salt is a trademark of its owner, Ansible is a trademark of Red Hat, Inc., and other names are trademarks of their owners. Gardience is independent and not affiliated with any of them.