atmos packer
Build reusable machine images with Packer using configuration from your Atmos stacks. Share image definitions across environments while varying their build settings through stack configuration.
Usage
For more details on the Packer commands and options, refer to Packer Commands.
Path-Based Component Resolution
Atmos supports using filesystem paths instead of component names for convenience. This allows you to navigate to a component directory and use . to reference it:
This automatically resolves the path to the component name configured in your stack, eliminating the need to remember exact component names.
Supported path formats:
.- Current directory./component- Relative path from current directory../other-component- Relative path to sibling directory/absolute/path/to/component- Absolute path
Requirements:
- Must be inside a component directory under the configured base path
- Must specify
--stackflag - Component must exist in the specified stack configuration
- The component path must resolve to a unique component name - If multiple components in the stack reference the same component path, you must use the unique component name instead of the path
Path-based resolution only works when the component path resolves to a single unique component in the stack.
For example, if both bastion/prod and bastion/dev reference components/packer/aws/bastion:
cd components/packer/aws/bastion
atmos packer build . --stack prod # ❌ Error: ambiguous - which component?
Instead, you must use the unique component names:
atmos packer build bastion/prod --stack prod # ✓ Explicit and unambiguous
atmos packer build bastion/dev --stack dev # ✓ Explicit and unambiguous
Atmos Flags
--stack(alias-s)Atmos stack.
--template(alias-t)(optional)Packer template file or directory path. Defaults to
.(component working directory), which tells Packer to load all*.pkr.hclfiles from the component directory.- Omit or use
.to load all HCL files (recommended for multi-file components) - Use a specific filename like
main.pkr.hclfor single-file templates
Can also be specified via
settings.packer.templatein the stack manifest. The command line flag takes precedence.- Omit or use
--query(alias-q)(optional)YQ expression to get sections and attributes from a Packer manifest. Used in the
atmos packer outputcommand.
Examples
Component Name Examples
Path-Based Examples
Learn how to configure Packer components in your atmos.yaml, including templates and component settings.
Arguments
atmos-component(required)Atmos component name or filesystem path.
Supports both:- Component names:
aws/bastion,gcp/web-server - Filesystem paths:
.(current directory),./aws/bastion,components/packer/aws/bastion
When using paths, Atmos automatically resolves the path to the component name based on your stack configuration. See Path-Based Component Resolution above.
- Component names:
Subcommands
Use this command to process a Packer template configured for an Atmos component in a stack, and build it to generate a set of artifacts.
Use this command to initialize Packer and install plugins according to an HCL template configuration for an Atmos component in a stack.
Use this command to inspect the various components that a Packer template configured for an Atmos component in a stack defines.
Use this command to get an output from a Packer manifest.
4 items
Use this command to validate the syntax and configuration of a Packer template configured for an Atmos component in a stack.
Use this command to display the currently installed Packer version.