atmos.GomplateDatasource
Stop hardcoding values in your infrastructure configurations. The atmos.GomplateDatasource function lets you pull live data from anywhere - APIs, cloud services, databases, files - directly into your Atmos stacks. Instead of manually updating IP addresses, account IDs, or configuration values, your infrastructure can fetch them automatically at runtime. Plus, with built-in caching, it's lightning fast even when you reference the same data hundreds of times.
What are Datasources?
Think of datasources as live connections to your data, wherever it lives. Instead of copying and pasting values into your configurations (and keeping them updated), datasources let Atmos fetch the latest data automatically when it runs.
The Problem: Traditional infrastructure configurations require you to:
- Hardcode values that change (IP addresses, account IDs, API keys)
- Manually update configurations when external systems change
- Duplicate data across multiple files
- Risk using outdated or incorrect values
The Solution: Datasources let you:
- Pull live data from any API, database, or cloud service
- Stay synchronized with external systems automatically
- Centralize configuration in its proper home (not in your IaC)
- Access secrets securely from vaults without exposing them
- Query cloud metadata like account IDs, regions, or resource tags dynamically
Real-World Example
Without Datasources (Manual, Error-Prone):
components:
terraform:
vpc:
vars:
account_id: "123456789012" # Hardcoded - wrong in other environments!
allowed_ip: "203.0.113.45" # Bob's IP - outdated when he moves
db_password: "prod-pass-123" # SECURITY RISK! Password in git
With Datasources (Dynamic, Secure):
components:
terraform:
vpc:
vars:
account_id: '{{ (atmos.GomplateDatasource "aws").account_id }}'
allowed_ip: '{{ (atmos.GomplateDatasource "myip").ip }}'
db_password: '{{ (atmos.GomplateDatasource "vault").database.password }}'
Common Use Cases
- Service Discovery: Query current IP addresses, endpoints, or service locations
- Dynamic Configuration: Fetch configuration values from external systems
- Secret Management: Retrieve secrets from HashiCorp Vault, AWS Secrets Manager, etc.
- Metadata Queries: Get AWS account info, region data, or resource tags
- External Data Import: Load data from CSV files, JSON APIs, or databases
Usage
{{ (atmos.GomplateDatasource "<alias>").<attribute> }}
Arguments
alias- The datasource alias defined in your Atmos configuration
attribute- Attribute name (field) to extract from the datasource response
Supported Datasource Types
Gomplate supports numerous datasource types:
- HTTP/HTTPS: REST APIs and web services
- File: Local files (JSON, YAML, TOML, CSV, etc.)
- AWS: Systems Manager Parameter Store, Secrets Manager, S3
- Cloud: Azure Key Vault, Google Cloud Storage
- Vault: HashiCorp Vault secrets
- Environment: Environment variables
- Git: Git repository data
- Consul: HashiCorp Consul key-value store