Hi @briancaffey,
Unfortunately the part of this which is surprising to me is that this worked for your alpha
workspace, since indeed Terraform refusing to work with a non-existing workspace is by design so that Terraform can catch typos that might, for example, lead to creating an entirely new parallel set of infrastructure when one intended to update some existing infrastructure.
To make this work you’ll need to introduce an extra step into your pipeline to explicitly create the workspace. Workspace creation requires having the backend initialized first, so you’ll need to wait until after terraform init
and terraform workspace create
before setting the environment variable. The sequence of steps would therefore be:
terraform init ...
terraform workspace create "${WORKSPACE}"
export TF_WORKSPACE="${WORKSPACE}"
terraform apply ...
terraform output ...
(Note that terraform apply -auto-approve
already has the Terraform planning step built into it if you aren’t also providing a saved plan file, so the extra terraform plan
step before that isn’t adding anything in your current pipeline; you’re just running the planning process twice.)