Source-Based Version Pinning
Source-Based Version Pinning enables native per-environment version control directly in stack configuration using the top-level source field. Components declare their source location inline, and Atmos vendors them just-in-time during executionβno separate vendor manifests or pre-vendoring required.
This approach provides strict version pinning with minimal operational overhead. Each environment can pin to specific versions while inheriting common source configuration through Atmos's stack inheritance system.
You will learn
- Native version pinning per environment without vendor.yaml files
- Just-in-time vendoring during terraform/helmfile execution
- Version inheritance through Atmos stack inheritance
- Simpler alternative to traditional vendoring for most use cases
- Supports all go-getter protocols (git, s3, http, oci, etc.)
Use Casesβ
Use Source-Based Version Pinning when:
- You need per-environment version control without vendor file overhead
- You want versions defined alongside other component configuration
- You need just-in-time vendoring without pre-vendoring steps
- You want to leverage stack inheritance for version defaults
- You're prototyping or iterating quickly on component versions
Problemβ
Traditional strict version pinning requires:
- Maintaining
vendor.yamlwith source definitions for each version - Running
atmos vendor pullbefore deployments - Committing vendored code to the repository
- Coordinating version updates across vendor manifests and stack configs
- Managing disk space for multiple vendored versions
This creates operational overhead, especially when different environments need different versions of many components.
Solutionβ
Use the source field directly in component configuration. The source provisioner handles just-in-time vendoring automatically.
String Form (Simple)β
For simple cases, specify a go-getter-compatible URI:
stacks/prod/us-east-1.yaml
Map Form (Full Control)β
For more control, use a map with explicit fields:
stacks/prod/us-east-1.yaml
Map Form with Retry Configurationβ
For unreliable networks or rate-limited sources, configure retry behavior:
stacks/prod/us-east-1.yaml
Retry options:
| Field | Default | Description |
|---|---|---|
max_attempts | 1 | Maximum number of download attempts |
initial_delay | 100ms | Initial delay before first retry |
max_delay | 5s | Maximum delay between retries |
backoff_strategy | exponential | Strategy: constant, linear, or exponential |
multiplier | 2.0 | Backoff multiplier for exponential/linear strategies |
random_jitter | 0.0 | Randomness added to delays (0.1 = 10%) |
max_elapsed_time | 30m | Maximum total time for all retries |
Version Inheritanceβ
Define source defaults in a catalog and override versions per environment:
- Catalog Defaults
- Development
- Production
stacks/catalog/vpc/defaults.yaml
stacks/dev/us-east-1.yaml
stacks/prod/us-east-1.yaml
How It Worksβ
Sources are automatically provisioned when running terraform commands:
# Just run terraform - source is provisioned automatically
atmos terraform plan vpc --stack dev
# β Auto-provisioning source for component 'vpc'
# β Auto-provisioned source to components/terraform/vpc
# β Terraform runs
Under the hood:
- Source Provisioner Hook: Registers for
before.terraform.initevent - Configuration Check: Extracts
sourcefrom component configuration - Skip if Exists: If target directory exists and is non-empty, skip provisioning
- Download: Uses go-getter to fetch component at specified version
- Path Filtering: Applies
included_pathsandexcluded_pathspatterns - Target Directory: Places component in the configured component path
- Execution: Terraform runs against the vendored component
The source provisioner only downloads if the component directory doesn't exist or is empty.
CLI Commandsβ
Explicit commands for managing sources:
# Vendor component source (downloads if missing or outdated)
atmos terraform source pull vpc --stack prod-us-east-1
# Force re-vendor even if up-to-date
atmos terraform source pull vpc --stack prod-us-east-1 --force
# List components with source configured
atmos terraform source list --stack prod-us-east-1
# Show source configuration
atmos terraform source describe vpc --stack prod-us-east-1
# Remove vendored source
atmos terraform source delete vpc --stack prod-us-east-1 --force
See atmos terraform source for complete CLI documentation.
Rollback Strategyβ
Rolling back is simpleβchange the version in your stack configuration:
# Before: problematic version
source:
version: 1.451.0
# After: rollback to stable version
source:
version: 1.450.0
Then apply:
# Force re-vendor to get previous version
atmos terraform source pull vpc --stack prod-us-east-1 --force
# Apply rollback
atmos terraform apply vpc --stack prod-us-east-1
Benefitsβ
- No vendor files to maintain: Version control happens in stack config
- No components committed to repo: Components don't bloat your repository if that's not adding value for your workflow
- Smaller repositories: No vendored Terraform code means smaller git repos and faster clones
- Per-environment versions: Each environment pins its own version natively
- Stack inheritance: Define defaults once, override where needed
- Just-in-time: No pre-vendor step in CI/CD pipelines
- Simple configuration: Fewer files, less coordination overhead
Drawbacksβ
- No local immutable copy: Components aren't committed, so you lose the audit trail in Git
- No pre-vendored code in repo: Can't review component diffs before deploy
- AI coding assistants lack context: Tools like Claude Code, Cursor, and GitHub Copilot work better with vendored code in the repoβthey can't see components that haven't been downloaded yet
- Requires network access: Components downloaded during execution
- No local modifications: Can't patch vendored components
- Less suitable for air-gapped: Needs external network access during deployment
- Harder to search codebase: Can't grep component code without first downloading it
When to Use Source vs Vendoringβ
| Requirement | Source | Vendoring |
|---|---|---|
| Per-environment versions | β | β |
| No vendor manifest files | β | β |
| Code review of dependencies | β | β |
| Offline deployment | β | β |
| Local modifications | β | β |
| Audit trail in Git | β | β |
| AI coding assistant context | β | β |
| Minimal operational overhead | β | β |
Best Practicesβ
- Use catalog defaults: Define base source config in catalogs
- Override only version: Inherit everything except version per environment
- Use map form for filtering: When you need to exclude files
- Consider vendoring for production-critical: When audit trails matter
- Pre-vendor in CI: Run
atmos terraform source pullin CI for faster deploys
Related Patternsβ
- Strict Version Pinning - Traditional approach using vendoring
- Vendoring Components - Pre-vendor for audit trails and offline use
- Folder-Based Versioning - Organize vendored versions in folders
- Release Tracks/Channels - Moving version targets vs fixed pins