-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No way to initialize PG backend in automation without non-zero exit code #23121
Comments
Once a workspace has been created,
|
Same for TF 0.12.16 terraform init does not create a record in the PG database for the default backend which is expected during the init flow... |
Same for @teamterraform any new on this ? |
If at least the fact that there's no workspace existing was reported as a separate exit code, we could catch it, and deal with it in automation. Right now, |
Yeah it's pretty ridiculous if you want to deal with this - we're catching the output of the commands and check if e.g. |
any update on this please? or is there a workaround |
I also would like this to be fixed the same way as local and other remote backends (for example, consul) do: create
|
@teamterraform any update please ? |
For those who would be interested, personally I deal with this bug via the before_script:
- terraform --version
- terraform init -backend-config="conn_str=postgres://${DB_USER}:${DB_PASSWORD}@postgres:5432/${DB_NAME}?sslmode=disable" || echo "Done !"
- terraform workspace new default || if [ $? -eq 0 ]; then echo "Done !"; else echo "Workspace \"default\" was not created"; fi
- terraform init I'm getting around the problem by catching the return code of |
Nice combo, @FlorianLaunay :D |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
It is not possible to initialize a PG backend when in automation without encountering one non-zero exit code
Terraform Version
Terraform Configuration Files
Debug Output
Trying to create a workspace before
terraform init
:Trying to run
terraform init
itself:Expected Behavior
I would expect
terraform init
to not exit with a non-zero status code or be allowed to useworkspace new
beforeinit
.Actual Behavior
Running
workspace new
withoutinit
does not work. Runninginit
by itself also fails. What I have to do is runinit
, expect non-zero exit code, then runworkspace new/select
.Steps to Reproduce
Create
backend.tf
with:Run
$ TF_AUTOMATION=yes TF_LOG=debug terraform workspace new foo
Run
TF_LOG=debug TF_AUTOMATION=yes terraform init -backend-config="conn_str=postgres://postgres:secret@127.0.0.1:3445/hydra?sslmode=disable" -input=false
The text was updated successfully, but these errors were encountered: