-
-
Notifications
You must be signed in to change notification settings - Fork 146
Description
Describe the Feature
In v1.163.0 change #1072 was implemented which sets the ATMOS_BASE_PATH for terraform commands. That looked like a great feature which would allow us to get rid of a certain workaround (explained below) but the implementation does not fix our issue.
We have base_path: '.' set in our atmos.yaml. That relative directory is relative to the current working directory and not the location of the atmos.yaml file. There is probably some use case for that but for us that means that we always have to set both ATMOS_CLI_CONFIG_PATH (cf. #1094) and ATMOS_BASE_PATH if we want to use the stack information from somewhere else.
IMO ATMOS_BASE_PATH should have been relative to ATMOS_CLI_CONFIG_PATH in the first place but that would probably break somebody's workflow somewhere. As a compromise I'd set the variable ATMOS_BASE_PATH to an absolute path at least the logic implemented in #1072. Because that relative path is probably useless for everybody when the internal chdir to the component directory happened and that feature is rather new so not too many people should be affected by that.
Expected Behavior
When I execute an atmos terraform foo the environment variable should point to the same location as it did when I called atmos. Ie. a relative directory in that config option should either be made absolute (easy) or relative to the component directory (more complicated and probably not worth it).
Use Case
We use the remote-state solution from https://docs.cloudposse.com/learn/maintenance/tutorials/how-to-use-terraform-remote-state/ and the internally used provider needs both ATMOS_CLI_CONFIG_PATH and ATMOS_BASE_PATH be set correctly to be able to read the stack configuration.
Describe Ideal Solution
Always evaluate ATMOS_BASE_PATH relative to ATMOS_CLI_CONFIG_PATH and not PWD.
Alternatives Considered
Our current workaround is a mixin which looks like this:
vars:
remote_state_env:
# Ensure that these environment variables are set to absolute directories
# or else the 'utils_component_config' call within the mixin will fail.
ATMOS_BASE_PATH: '{{with $d := env "ATMOS_BASE_PATH"}}{{if $d | isAbs}}{{$d}}{{else}}{{fail "ATMOS_BASE_PATH must be absolute"}}{{end}}{{else}}{{env "PWD"}}{{end}}'
ATMOS_CLI_CONFIG_PATH: '{{with $d := env "ATMOS_CLI_CONFIG_PATH"}}{{if $d | isAbs}}{{$d}}{{else}}{{fail "ATMOS_CLI_CONFIG_PATH must be absolute"}}{{end}}{{else}}{{env "PWD"}}{{end}}'Additional Context
No response