Skip to main content

!cwd

The !cwd Atmos YAML function retrieves the current working directory where Atmos is executed from.

Usage

The !cwd function can be called with or without a relative path:

# Get the current working directory
base_path: !cwd

# Get CWD joined with a relative path
base_path: !cwd ./relative/path

Why Use !cwd

By default, relative paths in atmos.yaml (like . and ..) are resolved relative to the config file location, not where you run the command. This follows the convention of other config files like tsconfig.json and package.json.

Use !cwd when you need paths relative to where Atmos is executed, such as:

  • Running Atmos from within a component directory with a shared config
  • Dynamic path resolution based on the current directory
  • Scripts that change directories before running Atmos

Examples

Basic Usage

# atmos.yaml
# base_path will be set to the current working directory
base_path: !cwd

With Relative Path

# atmos.yaml
# base_path will be CWD + ./components
base_path: !cwd ./components

Component-Relative Execution

A common use case is running Atmos from within a component directory while pointing to a shared configuration:

# Repository structure:
# /repo/
# atmos.yaml # shared config with base_path: !cwd
# components/terraform/vpc/
# main.tf

# When running from within a component:
cd /repo/components/terraform/vpc
ATMOS_CLI_CONFIG_PATH=/repo atmos terraform plan vpc -s prod

# base_path resolves to /repo/components/terraform/vpc (the CWD)

Comparison with Other Path Options

ConfigurationResolves toUse when
base_path: "."Config file directoryPaths should be relative to atmos.yaml
base_path: !cwdCurrent working directoryPaths should be relative to where you run from
base_path: !repo-rootGit repository rootPaths should be relative to repo root
base_path: ""Git root with fallback to config dirSmart default behavior

See Also