Description
When a project defines both deploy.server (with host: ${EXISTING_SERVER_HOST}) and deploy.cloud, running stacker deploy --target cloud still fails if EXISTING_SERVER_HOST is not present in .env, even though the server section is never used for a cloud deploy.
Steps to Reproduce
# stacker.yml
deploy:
target: server
server:
host: ${EXISTING_SERVER_HOST}
user: ${EXISTING_SERVER_USER}
ssh_key: ${BASE_PATH}/stacker-project-test
cloud:
provider: hetzner
region: fsn1
size: cpx22
public_ports:
- "3579"
With a fresh .env that has only the app's secrets (no EXISTING_SERVER_HOST):
stacker deploy --target cloud --key htz-0 --force-new
Result:
Error: Environment variable not found: $EXISTING_SERVER_HOST
stacker config validate fails with the same error.
Expected Behavior
--target cloud should ignore deploy.server entirely — env var substitution should only apply to the sections that are actually used for the selected target. The command should deploy successfully with just the cloud section vars present.
Actual Behavior
The CLI resolves env vars for deploy.server even when deploying to cloud, so every new project that doesn't pre-seed the server vars fails before deployment starts.
Impact
- Confusing for the dual-target pattern (server + cloud in one
stacker.yml), which is the recommended layout in this repo (see SKILL.md §15).
- New projects can't be cloud-deployed without manually copying unrelated server env vars into
.env.
stacker config validate also fails, blocking CI-style preflight checks.
Suggested Fix
Filter env-var substitution by the active target: resolve deploy.cloud.* vars for cloud deploys, deploy.server.* for server deploys, and skip the inactive branch entirely.
Environment
- Stacker CLI: 0.3.1
- Cloud provider: Hetzner (htz-0 / htz-13)
Description
When a project defines both
deploy.server(withhost: ${EXISTING_SERVER_HOST}) anddeploy.cloud, runningstacker deploy --target cloudstill fails ifEXISTING_SERVER_HOSTis not present in.env, even though the server section is never used for a cloud deploy.Steps to Reproduce
With a fresh
.envthat has only the app's secrets (noEXISTING_SERVER_HOST):Result:
stacker config validatefails with the same error.Expected Behavior
--target cloudshould ignoredeploy.serverentirely — env var substitution should only apply to the sections that are actually used for the selected target. The command should deploy successfully with just the cloud section vars present.Actual Behavior
The CLI resolves env vars for
deploy.servereven when deploying to cloud, so every new project that doesn't pre-seed the server vars fails before deployment starts.Impact
stacker.yml), which is the recommended layout in this repo (see SKILL.md §15)..env.stacker config validatealso fails, blocking CI-style preflight checks.Suggested Fix
Filter env-var substitution by the active target: resolve
deploy.cloud.*vars for cloud deploys,deploy.server.*for server deploys, and skip the inactive branch entirely.Environment