Skip to content
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

Terraform Plan Exitcode Not 2 as expected when there's updates. #417

Closed
Dipak-Mistry-WTW opened this issue May 20, 2024 · 2 comments
Closed

Comments

@Dipak-Mistry-WTW
Copy link

When using Githust hosted runner the exitcode is set to 0 from Terraform plan step even when there are updates. At the end of the plan step I see:

##[debug]Saved the plan to: dev.tfplan
##[debug]
##[debug]To perform exactly these actions, run the following command to apply:
##[debug]    terraform apply "dev.tfplan"
##[debug]Releasing state lock. This may take a few moments...
##[debug]
##[debug]Set output stderr = 
##[debug]Set output exitcode = 2
##[debug]Set output exitcode = 0
##[debug]Finishing: Terraform Plan

Then in the Complete Job step I see:

##[debug]Starting: Complete job
Evaluate and set job outputs
##[debug]Evaluating: steps.tf-plan.outputs.exitcode
##[debug]Evaluating Index:
##[debug]..Evaluating Index:
##[debug]....Evaluating Index:
##[debug]......Evaluating steps:
##[debug]......=> Object
##[debug]......Evaluating String:
##[debug]......=> 'tf-plan'
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'outputs'
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'exitcode'
##[debug]=> '0'
##[debug]Result: '0'
Set output 'tfplanExitCode'
Cleaning up orphan processes
##[debug]Finishing: Complete job

The next job needs exitcode of 2 to run the terraform apply step.

@np5
Copy link

np5 commented Jul 10, 2024

The wrapper that is installed by default masks the exit code. You can use the action with the terraform_wrapper: false option, or you can change your tests to check for the outputs that the wrapper is already setting up.

@Dipak-Mistry-WTW
Copy link
Author

@np5 Thanks - I added the option to set the wrapper to false. That's all I needed.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants