Backends Auto-Provisioned on Terraform Init
Atmos now automatically provisions backends during terraform init, eliminating the need for a separate backend create command. When provision.backend.enabled: true is set, backends are created just-in-time during your first Terraform operation.
What Changed
Previously, automatic backend provisioning required running atmos terraform backend create explicitly before initializing Terraform. Now, backends are provisioned automatically when you run any Terraform command that triggers initialization:
# Before: Two commands required
atmos terraform backend create vpc -s dev
atmos terraform plan vpc -s dev
# After: Single command - backend auto-provisioned on init
atmos terraform plan vpc -s dev
# ⠋ Provisioning S3 backend `my-terraform-state` for `vpc` in stack `dev`...
# ✓ Provisioned S3 backend `my-terraform-state` for `vpc` in stack `dev`
# ... terraform init continues automatically
How It Works
When provision.backend.enabled: true is configured, Atmos registers a hook that runs before terraform init:
- Check if enabled - Silent skip if
provision.backend.enabledis nottrue - Check if exists - Silent skip if backend already exists (idempotent)
- Provision with feedback - Create backend with spinner showing progress
- Continue init - Terraform initialization proceeds automatically
This behavior is completely opt-in. Without the provision configuration, nothing changes.
Configuration
The configuration remains the same - just add provision.backend.enabled: true:
components:
terraform:
vpc:
backend_type: s3
backend:
bucket: my-terraform-state
key: vpc/terraform.tfstate
region: us-east-1
provision:
backend:
enabled: true
You can also set this at the global terraform level for all components:
terraform:
provision:
backend:
enabled: true
components:
terraform:
vpc:
# Inherits provision.backend.enabled: true from above
backend_type: s3
backend:
bucket: my-terraform-state
key: vpc/terraform.tfstate
region: us-east-1
UX Improvements
This release also includes improved output formatting:
- Spinner feedback - Visual progress indicator during provisioning
- Consolidated messages - Single line output instead of multiple status messages
- Backend type and name - Shows backend type (S3, GCS, etc.) and resource name (bucket)
- Markdown-friendly formatting - Backticks around names render correctly in terminals
Idempotent Behavior
The auto-provisioning is idempotent:
- First run: Backend is created with spinner feedback
- Subsequent runs: Silent skip (backend already exists)
- After Terraform import: Safe to leave enabled - no conflicts
This means you can safely leave provision.backend.enabled: true in your configuration permanently.
Explicit Command Still Available
The explicit backend create command remains available for CI/CD pipelines or manual provisioning:
atmos terraform backend create vpc -s dev
Getting Started
Enable automatic backend provisioning in your stack configuration and run any Terraform command:
atmos terraform plan vpc -s dev
That's it - no separate provisioning step required.
For more details, see our original announcement and CLI documentation.
