Sources
The sources key in vendor.yaml defines the list of components and artifacts to vendor. Each source specifies where to download from, what version, and where to place the files.
Schemaβ
spec:
sources:
- component: "vpc"
source: "github.com/org/repo.git//path?ref={{.Version}}"
version: "1.0.0"
targets:
- "components/terraform/vpc"
included_paths:
- "**/*.tf"
excluded_paths:
- "**/test/**"
tags:
- networking
Attributesβ
componentThe
componentattribute in each source is optional. It's used in theatmos vendor pull --component <component>command if the component is passed in. In this case, Atmos will vendor only the specified component instead of vendoring all the artifacts configured in thevendor.yamlmanifest.versionThe
versionattribute is used to specify the version of the artifact to download. Theversionattribute is used in thesourceandtargetsattributes as a template parameter using{{ .Version }}.sourceThe
sourceattribute supports all protocols (local files, Git, Mercurial, HTTP, HTTPS, Amazon S3, Google GCP), and all the URL and archive formats as described in go-getter, and also theoci://scheme to download artifacts from OCI registries.See Vendor URL Syntax for complete documentation on supported URL formats, authentication, and subdirectory syntax.
IMPORTANT: Include the
{{ .Version }}parameter in yoursourceURI to ensure the correct version of the artifact is downloaded.For example, for
httpandhttpssources, use the following format:source: "github.com/cloudposse-terraform-components/aws-vpc-flow-logs-bucket.git?ref={{.Version}}"refPass the
refas a query string with either the tag, branch, or commit hash to download the correct version of the artifact. e.g.?ref={{.Version}}will pass theversionattribute to therefquery string.depthPass the
depthas a query string to download only the specified number of commits from the repository. e.g.?depth=1will download only the latest commit.
targetsThe
targetsin each source supports absolute paths and relative paths (relative to thevendor.yamlfile). Note: if thetargetspaths are set as relative, and if thevendor.yamlfile is detected by Atmos using thebase_pathsetting inatmos.yaml, thetargetspaths will be considered relative to thebase_path. Multiple targets can be specified.included_pathsandexcluded_pathsincluded_pathsandexcluded_pathssupport POSIX-style greedy Globs for filenames/paths (double-star/globstar**is supported as well). For more details, see Vendoring with Globs below.tagsThe
tagsin each source specifies a list of tags to apply to the component. This allows you to only vendor the components that have the specified tags by executing a commandatmos vendor pull --tags <tag1>,<tag2>
Template Parametersβ
The source and targets attributes support Go templates and Sprig Functions.
{{ .Component }}Refers to the
componentattribute in the current section. Thecomponentattribute is used to specify the component name. This is useful to vendor components into folders by the same name.targets:
- "components/terraform/{{ .Component }}"{{ .Version }}Refers to the
versionattribute the current section. Theversionattribute is used to specify the version of the artifact to download. This is useful to version components into different folders.targets:
- "components/terraform/{{ .Component }}/{{ .Version }}"When stacks need to pin to different versions of the same component, the
{{ .Version }}template parameter can be used to ensure the components are vendored into different folders.
You can also use any of the hundreds of go-template functions. For example, to extract the major and minor version from the {{ .Version }} attribute, use the following template:
targets:
- "components/terraform/{{ .Component }}/{{ (first 2 (splitList \".\" .Version)) | join \".\" }}"
Authenticating to Private Git Repositoriesβ
Atmos provides automatic token injection for private repositories on GitHub, GitLab, and Bitbucket. This is the recommended approach for most users.
The easiest and most secure way to authenticate to private Git repositories is to use Atmos's automatic token injection.
Step 1: Set the authentication token as an environment variable:
export GITHUB_TOKEN="your-personal-access-token"
# or
export ATMOS_GITHUB_TOKEN="your-personal-access-token"
Step 2: Use simple URLs in your vendor.yaml (no manual credentials):
sources:
- component: "vpc"
source: "github.com/your-org/private-repo.git//terraform/vpc?ref={{.Version}}"
version: "1.0.0"
targets:
- "components/terraform/vpc"
Step 3: Atmos automatically injects the token when downloading.
Supported environment variables:
- GitHub:
ATMOS_GITHUB_TOKENorGITHUB_TOKEN - GitLab:
ATMOS_GITLAB_TOKENorGITLAB_TOKEN - Bitbucket:
ATMOS_BITBUCKET_TOKENorBITBUCKET_TOKEN
Token injection settings in atmos.yaml:
inject_github_token: true(default: true) - Enables automatic GitHub token injectioninject_gitlab_token: true(default: false) - Enables automatic GitLab token injectioninject_bitbucket_token: true(default: false) - Enables automatic Bitbucket token injection
The GITHUB_TOKEN provided by GitHub Actions is only valid for the current repository, or repositories marked as internal within GitHub Enterprise organizations. For cross-repository access, provision a fine grained personal access token with the necessary permissions.
Vendoring from OCI Registriesβ
Atmos supports vendoring from OCI registries.
To specify a repository in an OCI registry, use the oci://<registry>/<repository>:tag scheme.
Artifacts from OCI repositories are downloaded as Docker image tarballs, then all the layers are processed, un-tarred and un-compressed,
and the files are written into the directories specified by the targets attribute of each source.
OCI Authenticationβ
Atmos uses the following precedence order for OCI registry authentication:
- Docker credentials (highest precedence) - Credentials from
docker loginstored in~/.docker/config.json - Environment variables - For GitHub Container Registry (ghcr.io):
- Token:
ATMOS_GITHUB_TOKENorGITHUB_TOKEN - Username:
ATMOS_GITHUB_USERNAME,GITHUB_ACTOR, orGITHUB_USERNAME
- Token:
- Anonymous - Fallback for public images
Exampleβ
vendor.yaml
To vendor the vpc component, execute the following command:
Vendoring with Globsβ
In Atmos, glob patterns define which files and directories are included or excluded during vendoring. These patterns go beyond simple wildcard characters like *βthey follow specific rules that dictate how paths are matched. Understanding the difference between greedy (**) and non-greedy (*) patterns, along with other advanced glob syntax, ensures precise control over vendoring behavior.
Understanding Wildcards, Ranges, and Recursionβ
Glob patterns in Atmos provide flexible and powerful matching, that's simpler to understand than regular expressions:
*(single asterisk)- Matches any sequence of characters within a single path segment.
- Example:
vendor/*.yamlmatchesvendor/config.yamlbut notvendor/subdir/config.yaml. **(double asterisk, also known as a "greedy glob")- Matches across multiple path segments recursively.
- Example:
vendor/**/*.yamlmatchesvendor/config.yaml,vendor/subdir/config.yaml, andvendor/deep/nested/config.yaml. ?(question mark)- Matches exactly one character in a path segment.
- Example:
file?.txtmatchesfile1.txtandfileA.txtbut notfile10.txt. [abc](character class)- Matches any single character inside the brackets.
- Example:
file[123].txtmatchesfile1.txt,file2.txt, andfile3.txt, but notfile4.txtorfile12.txt. [a-z](character range)- Matches any single character within the specified range.
- Example:
file[a-c].txtmatchesfilea.txt,fileb.txt, andfilec.txt. {a,b,c}(brace expansion)- Matches any of the comma-separated patterns.
- Example:
*.{jpg,png,gif}matchesimage.jpg,image.png, andimage.gif.
This distinction is important when excluding specific directories or files while vendoring.
Example: Excluding a Subdirectoryβ
Consider the following configuration:
included_paths:
- "**/demo-library/**"
excluded_paths:
- "**/demo-library/**/stargazers/**"
How it works:
- The
included_pathsrule**/demo-library/**ensures all files insidedemo-library(at any depth) are vendored. - The
excluded_pathsrule**/demo-library/**/stargazers/**prevents any files insidestargazerssubdirectories from being vendored.
This means:
- All files within
demo-libraryexcept those inside anystargazerssubdirectory are vendored. - Any other files outside
stargazersare unaffected by this exclusion.
Example: Matching Multiple File Extensionsβ
included_paths:
- "**/demo-library/**/*.{tf,md}"
This is equivalent to writing:
included_paths:
- "**/demo-library/**/*.tf"
- "**/demo-library/**/*.md"
The {tf,md} part expands to both *.tf and *.md, making the rule more concise.
Key Takeawaysβ
- Use
**/for recursive matching to include everything inside a directory. - Use
*for single-segment matches, which won't include deeper subdirectories. - Use
{...}to match multiple extensions or directories within a single pattern. - Exclusion rules must match nested paths explicitly when trying to exclude deep directories.