Automatic Backend Provisioning
Atmos can automatically provision S3 backend infrastructure before running Terraform commands. This eliminates the manual bootstrapping step of creating state storage.
- Terraform Backends - Configure where state is stored
- Remote State - Read other components' state
atmos terraform backend- CLI commands for backend management
Configuration
Enable automatic provisioning in your stack manifests using the provision.backend.enabled setting:
When enabled, Atmos will:
- Check if the backend exists before running Terraform commands
- Provision the backend if it doesn't exist (with secure defaults)
- Continue with Terraform initialization and execution
Configuration Hierarchy
The provision.backend configuration leverages Atmos's deep-merge system, allowing you to set defaults at high levels and override per component.
Organization-Level Defaults
Enable provisioning for all components in development environments:
Environment-Specific Overrides
Configure different provisioning policies per environment:
Component Inheritance
Share provision configuration through catalog components:
Component-Level Override
Override for specific components:
Deep-Merge Behavior: Atmos combines configurations from all levels, giving you maximum flexibility:
- Set defaults at organization or environment level
- Override per component when needed
- Use catalog inheritance for reusable patterns
- Component-level configuration has highest precedence
Supported Backend Types
S3 (AWS)
The S3 backend provisioner creates buckets with hardcoded security best practices:
- Versioning: Enabled (protects against accidental deletions)
- Encryption: AES-256 with AWS-managed keys (always enabled)
- Public Access: Blocked (all 4 block settings enabled)
- Locking: Native S3 locking (Terraform 1.10+, no DynamoDB required)
- Tags: Automatic resource tags (
Name,ManagedBy=Atmos)
Required Configuration:
Cross-Account Provisioning:
The provisioner will assume the specified role to create the bucket in the target account.
Manual Provisioning
You can also provision backends explicitly using the CLI:
This is useful for:
- CI/CD pipelines with separate provisioning stages
- Troubleshooting provisioning issues
- Batch provisioning for multiple components
- Pre-provisioning before large-scale deployments
See atmos terraform backend for complete CLI documentation.
Required IAM Permissions
For S3 backend provisioning, the identity needs these permissions:
For cross-account provisioning, also add:
Solving the Terraform Bootstrap Problem
Automatic provisioning is fully compatible with Terraform-managed backends. It solves a classic chicken-and-egg problem: "How do I manage my state backend with Terraform when I need that backend to exist before Terraform can run?"
Traditional Workaround:
- Use local state temporarily
- Create S3 bucket with Terraform using local state
- Switch backend configuration to S3
- Import the bucket into the S3-backed state
- Delete local state files
With Atmos Automatic Provisioning:
- Enable
provision.backend.enabled: true - Run
atmos terraform plan- backend auto-created with secure defaults - Import the bucket into Terraform (no local state dance needed)
- Done - everything managed by Terraform
Migrating to Terraform-Managed Backends
Once your backend is provisioned, you can import it into Terraform for advanced management:
Step 1: Provision the Backend
Use Atmos to create the backend with secure defaults:
Step 2: Import into Terraform
Add the backend to your Terraform configuration and import it:
Step 3: Optionally Disable Automatic Provisioning
Once Terraform manages the backend, you can optionally disable automatic provisioning:
Note: You can leave provision.backend.enabled: true even after importing to Terraform. The provisioner is idempotent - it will detect the bucket exists and skip creation, causing no conflicts with Terraform management.
Alternatively, use the terraform-aws-tfstate-backend module for backends with advanced features like cross-region replication, lifecycle policies, and custom KMS keys.
Idempotent Operations
Backend provisioning is idempotent—running it multiple times is safe:
References
- Terraform Backends - Configure backend storage
- Remote State - Read other components' state
atmos terraform backend- CLI commands- Terraform Backend Configuration
terraform-aws-tfstate-backend- Advanced backend module