# env

The `env` field exports environment variables to every step in a custom command. Values support Go templates, so they can be built from arguments, flags, and component configuration.

```yaml
commands:
  - name: provision
    description: Provision a component
    arguments:
      - name: component
        description: Name of the component
    flags:
      - name: stack
        shorthand: s
        description: Name of the stack
        required: true
    # ENV var values support Go templates
    env:
      - key: ATMOS_COMPONENT
        value: "{{ .Arguments.component }}"
      - key: ATMOS_STACK
        value: "{{ .Flags.stack }}"
    steps:
      - atmos terraform plan $ATMOS_COMPONENT -s $ATMOS_STACK
      - atmos terraform apply $ATMOS_COMPONENT -s $ATMOS_STACK
```

The variables are exported as real environment variables, so steps (and any scripts they invoke) read them with the usual `$NAME` syntax.

## Fields

- **`key`** — Required. Environment variable name.
- **`value`** — Static or templated value. Supports Go templates such as `{{ .Arguments.* }}`, `{{ .Flags.* }}`, and `{{ .ComponentConfig.* }}`.
- **`valueCommand`** — A command whose stdout becomes the variable's value. Use either `value` or `valueCommand`, not both.

:::tip
For secrets, prefer a [custom component type](/cli/configuration/commands/component) with an `env`
section sourced from [`!secret`](/functions/yaml/secret), rather than inlining secret values into
`value`.
:::
