Vendor URL Syntax
Atmos vendor sources support a wide variety of URL schemes and path formats for pulling external components, stacks, and configurations. Understanding the URL syntax helps you effectively vendor dependencies from any source.
URL Schemes
Atmos vendoring is built on HashiCorp's go-getter library, with additional support for OCI registries and smart defaults for Git hosting platforms.
Supported Schemes
Scheme | Description | Example |
---|---|---|
(no scheme) | Implicit HTTPS for Git hosts | github.com/owner/repo.git?ref=v1.0 |
https:// | HTTPS protocol | https://github.com/owner/repo.git//path?ref=v1.0 |
git:: | Explicit Git protocol | git::https://github.com/owner/repo.git?ref=v1.0 |
oci:// | OCI registries (Atmos extension) | oci://ghcr.io/owner/image:tag |
file:// | Local filesystem | file:///absolute/path/to/components |
ssh:// | SSH protocol | ssh://git@github.com/owner/repo.git |
SCP-style | SSH shorthand | git@github.com:owner/repo.git |
Most of the time, you can use the simplest form without an explicit scheme. Atmos will automatically detect the right protocol.
Subdirectory Syntax
One of the most powerful features is the subdirectory delimiter that lets you vendor only a specific directory from a repository.
The Double-Slash Delimiter
The double-slash (//
) is a special delimiter (not a path separator) that separates:
- Left side: The source to download (repository URL, archive, etc.)
- Right side: The subdirectory within that source to extract
- With Subdirectory
- Root Directory
- Without Delimiter
source: "github.com/cloudposse-terraform-components/aws-vpc.git//modules/public-subnets?ref=1.398.0"
Result: Clones the repository and extracts only the modules/public-subnets
subdirectory.
source: "github.com/cloudposse-terraform-components/aws-s3-bucket.git//.?ref=v5.7.0"
Result: Clones the repository and uses the root directory (.
means current directory).
source: "github.com/cloudposse-terraform-components/aws-vpc.git?ref=v1.0"
Result: For Git URLs without a subdirectory, Atmos automatically adds //.
for you (root of repository).
Common Patterns
Pattern | What It Means | When To Use |
---|---|---|
repo.git//path/to/dir | Extract path/to/dir subdirectory | When you only need a specific directory |
repo.git//. | Extract root directory | When you need the entire repository |
repo.git | No subdirectory specified | Atmos adds //. automatically for Git URLs |
The triple-slash pattern (///
) was used in older Atmos versions to indicate the root directory:
# Old syntax (still works but deprecated)
source: "github.com/owner/repo.git///?ref=v1.0"
# New syntax (explicit and clear)
source: "github.com/owner/repo.git//.?ref=v1.0"
Atmos automatically normalizes the triple-slash pattern for backward compatibility, but we recommend using //.
for clarity.
Query Parameters
Query parameters are appended to the URL and control how the source is downloaded.
Common Parameters
Parameter | Description | Example |
---|---|---|
ref=<value> | Git reference (branch, tag, commit) | ?ref=main or ?ref=v1.0.0 |
depth=<n> | Git clone depth (shallow clone) | ?depth=1 |
sshkey=<path> | Path to SSH private key | ?sshkey=~/.ssh/id_rsa |
Atmos automatically adds depth=1
to Git clones for faster downloads. You can override this by explicitly setting depth
.
Examples
- Git Tag
- Git Branch
- Git Commit SHA
- Custom Clone Depth
source: "github.com/cloudposse-terraform-components/aws-vpc.git?ref=v1.398.0"
source: "github.com/cloudposse/atmos.git//examples?ref=main"
source: "github.com/cloudposse-terraform-components/aws-vpc.git?ref=a1b2c3d4"
source: "github.com/cloudposse-terraform-components/aws-vpc.git?ref=main&depth=10"
URL Patterns by Platform
- GitHub
- GitLab
- Bitbucket
- Azure DevOps
- Self-Hosted Git
- OCI Registries
Implicit HTTPS (recommended)
# Simple - implicit HTTPS, root directory
source: "github.com/cloudposse-terraform-components/aws-vpc.git?ref=v1.398.0"
With Subdirectory
# Clone and extract specific subdirectory
source: "github.com/cloudposse-terraform-components/aws-vpc.git//modules/public-subnets?ref=v1.398.0"
Explicit git:: Protocol
# Explicit git protocol
source: "git::https://github.com/cloudposse/atmos.git//examples?ref=main"
SSH Authentication
# SSH protocol (requires SSH key setup)
source: "git::ssh://git@github.com/cloudposse-terraform-components/aws-vpc.git?ref=v1.0.0"
# Or SCP-style shorthand
source: "git@github.com:cloudposse-terraform-components/aws-vpc.git?ref=v1.0.0"
With Credentials (Not Recommended)
# HTTPS with embedded credentials (not recommended, use tokens)
source: "https://user:password@github.com/owner/repo.git?ref=v1.0"
Atmos automatically injects GitHub tokens from ATMOS_GITHUB_TOKEN
or GITHUB_TOKEN
environment variables. No need to embed credentials in URLs!
Implicit HTTPS
# Simple - implicit HTTPS
source: "gitlab.com/group/project.git?ref=v1.0.0"
With Subdirectory
# Extract specific directory
source: "gitlab.com/group/project.git//terraform/modules?ref=main"
Set ATMOS_GITLAB_TOKEN
or GITLAB_TOKEN
for automatic authentication.
Implicit HTTPS
# Simple - implicit HTTPS
source: "bitbucket.org/owner/repo.git?ref=main"
With Subdirectory
# Extract specific directory
source: "bitbucket.org/owner/repo.git//infrastructure?ref=main"
Set ATMOS_BITBUCKET_TOKEN
or BITBUCKET_TOKEN
for automatic authentication.
Azure DevOps Repositories
# Azure DevOps Git repositories
source: "dev.azure.com/organization/project/_git/repository//path?ref=main"
Self-Hosted Git Servers
# Any self-hosted Git server
source: "git.company.com/team/repository.git//modules?ref=v1.0.0"
# With explicit HTTPS
source: "https://git.company.com/team/repository.git?ref=v1.0.0"
Atmos supports pulling artifacts from OCI-compatible registries like GitHub Container Registry (ghcr.io), AWS ECR, Google Artifact Registry, and more.
OCI Syntax
source: "oci://<registry>/<namespace>/<image>:<tag>"
GitHub Container Registry
source: "oci://ghcr.io/cloudposse/components/vpc:v1.0.0"
AWS ECR Public
source: "oci://public.ecr.aws/cloudposse/components/terraform/stable/aws/vpc:latest"
Docker Hub
source: "oci://docker.io/library/nginx:alpine"
OCI registries use standard container registry authentication. Ensure you're logged in with docker login
or equivalent.
Local Paths
Relative Paths
# Relative to vendor.yaml location
source: "../../../components/terraform/mixins"
Absolute Paths
# Absolute filesystem path
source: "/absolute/path/to/components"
file:// URI
# file:// URI (gets converted to absolute path)
source: "file:///path/to/local/components"
Atmos validates local paths to prevent directory traversal attacks. Paths with ..
are carefully validated.
HTTP/HTTPS Downloads
Archive Files
# Download and extract archives
source: "https://example.com/components.tar.gz"
source: "https://example.com/components.zip"
Single Files
# Download a single file
source: "https://raw.githubusercontent.com/cloudposse/terraform-null-label/0.25.0/exports/context.tf"
Template Variables
Atmos supports Go templates in vendor URLs for dynamic configuration.
Available Variables
Variable | Description | Example |
---|---|---|
{{.Component}} | Component name | Replaced with the value of component: field |
{{.Version}} | Component version | Replaced with the value of version: field |
Example
sources:
- component: "vpc"
source: "github.com/cloudposse-terraform-components/aws-{{.Component}}.git?ref={{.Version}}"
version: "1.398.0"
targets:
- "components/terraform/{{.Component}}"
Result: Downloads from aws-vpc
repository at version 1.398.0
to components/terraform/vpc
.
Authentication
Token Injection
Atmos automatically injects tokens for supported platforms:
Platform | Environment Variables | Username |
---|---|---|
GitHub | ATMOS_GITHUB_TOKEN or GITHUB_TOKEN | x-access-token |
GitLab | ATMOS_GITLAB_TOKEN or GITLAB_TOKEN | oauth2 |
Bitbucket | ATMOS_BITBUCKET_TOKEN or BITBUCKET_TOKEN | x-token-auth |
SSH Keys
For SSH-based Git access:
# SSH with default key (~/.ssh/id_rsa)
source: "git@github.com:owner/private-repo.git?ref=main"
# SSH with custom key
source: "git@github.com:owner/private-repo.git?ref=main&sshkey=~/.ssh/custom_key"
Embedded Credentials
# Not recommended: credentials in URL
source: "https://username:password@github.com/owner/repo.git?ref=v1.0"
Embedding credentials in URLs is not recommended. Use environment variables for tokens or SSH keys instead.
Best Practices
1. Use Explicit Versions
- ✅ Good
- ❌ Avoid
# Pin to specific version
source: "github.com/cloudposse-terraform-components/aws-vpc.git?ref=v1.398.0"
# Unpinned version (follows branch HEAD)
source: "github.com/cloudposse-terraform-components/aws-vpc.git?ref=main"
2. Use Subdirectories When Needed
# ✅ Extract specific subdirectory from a repository
source: "github.com/cloudposse-terraform-components/aws-vpc.git//modules/public-subnets?ref=v1.398.0"
# ✅ Use root directory (no subdirectory needed)
source: "github.com/cloudposse-terraform-components/aws-vpc.git?ref=v1.398.0"
3. Use Token Authentication
4. Prefer OCI for Binary Artifacts
# ✅ OCI for container images and binary artifacts
source: "oci://ghcr.io/cloudposse/components/terraform/stable/aws/vpc:v1.0.0"
# ✅ Git for source code
source: "github.com/cloudposse-terraform-components/aws-vpc.git?ref=v1.398.0"
Troubleshooting
Empty Directories After Vendor Pull
Symptom: atmos vendor pull
creates directories but no files are pulled.
Causes:
- Using triple-slash (
///
) instead of double-slash-dot (//.
) for root directory - Incorrect subdirectory path
- Files excluded by
excluded_paths
orincluded_paths
glob patterns
Solution:
# ✅ Correct: Use //. for root
source: "github.com/owner/repo.git//.?ref=v1.0"
# ❌ Avoid: Triple-slash (deprecated)
source: "github.com/owner/repo.git///?ref=v1.0"
Authentication Failures
Symptom: fatal: Authentication failed
or permission denied
Solution:
- Verify token is set:
echo $ATMOS_GITHUB_TOKEN
- Check token has correct permissions (repo access)
- For SSH: Verify SSH keys are set up (
ssh -T git@github.com
)
Rate Limits
Symptom: API rate limit exceeded
Solution: Set authentication tokens to increase rate limits:
- GitHub: 60 req/hr (unauthenticated) → 5,000 req/hr (authenticated)
- GitLab: Similar improvements with tokens
- Bitbucket: Token required for most operations
Related Documentation
- Vendor Manifest - Complete vendor.yaml reference
- Vendor Pull Command - CLI command documentation
- go-getter Documentation - Underlying library reference
- OCI Distribution Spec - OCI registry specification