# atmos packer output

Use this command to get an output from a Packer manifest.
Manifests are generated by Packer when executing `packer build` commands (if configured in the Packer template and Atmos stack).
[YQ](https://mikefarah.gitbook.io/yq/) expressions and functions are supported to get any section or attribute from the manifest.

## Usage

Execute the `packer output` command like this:

```shell
atmos packer output <component> --stack <stack> --query <yq-expression>
```

:::note
`atmos packer output` command is specific to Atmos (Packer itself does not have an `output` command).
The command is used to get an output from a Packer manifest.
Manifests are generated by Packer when executing `packer build` commands (if configured in the Packer template and Atmos stack).
:::

## Arguments

- **`component` (required)**

  Atmos Packer component.

## Flags

- **`--stack` (alias `-s`)(required)**

  Atmos stack.
- **`--query` (alias `-q`)(optional)**

  [YQ](https://mikefarah.gitbook.io/yq/) expression to get sections and attributes from a [Packer manifest](https://developer.hashicorp.com/packer/docs/post-processors/manifest).

## Examples

```shell
atmos packer output aws/bastion -s prod
atmos packer output aws/bastion -s prod --query '.builds[0].artifact_id'
atmos packer output aws/bastion -s prod -q '.builds[0].artifact_id | split(":")[1]'
```

```shell
> atmos packer output aws/bastion -s prod

builds:
- artifact_id: us-east-2:ami-0c2ca16b7fcac7529
  build_time: 1.753281956e+09
  builder_type: amazon-ebs
  custom_data: null
  files: null
  name: al2023
  packer_run_uuid: 5114a723-92f6-060f-bae4-3ac2d0324557
- artifact_id: us-east-2:ami-0b2b3b68aa3c5ada8
  build_time: 1.7540253e+09
  builder_type: amazon-ebs
  custom_data: null
  files: null
  name: al2023
  packer_run_uuid: a57874d1-c478-63d7-cfde-9d91e513eb9a
  last_run_uuid: a57874d1-c478-63d7-cfde-9d91e513eb9a
```

```shell
# Use a YQ expression to get a specific section or attribute from the Packer manifest,
# in this case, the `artifact_id` from the first build.

> atmos packer output aws/bastion -s nonprod --query '.builds[0].artifact_id'

us-east-2:ami-0c2ca16b7fcac7529
```

```shell
# Use a YQ expression to get a specific section or attribute from the Packer manifest,
# in this case, the AMI (second part after the `:`) from the `artifact_id` from the first build.

> atmos packer output aws/bastion -s nonprod -q '.builds[0].artifact_id | split(":")[1]'

ami-0c2ca16b7fcac7529
```
