Skip to content

fix: fail step on non-zero exit code#352

Open
wilsonjord wants to merge 1 commit intomainfrom
fix-terrform-fmt-errors
Open

fix: fail step on non-zero exit code#352
wilsonjord wants to merge 1 commit intomainfrom
fix-terrform-fmt-errors

Conversation

@wilsonjord
Copy link
Contributor

Currently, terraform errors for terraform fmt are not failing the build:
https://github.com/GeoNet/terraform-aws/actions/runs/22419354659/job/64913111658

Run terraform fmt -check -diff=true -recursive
╷
│ Error: Unclosed configuration block
│ 
│   on modules/ecs_docker_task_ng/main.tf line 851, in resource "aws_iam_role_policy" "ecs_taskprotection_policy":
│  851: resource "aws_iam_role_policy" "ecs_taskprotection_policy" {
│ 
│ There is no closing brace for this block before the end of the file. This
│ may be caused by incorrect brace nesting elsewhere in this file.
╵

The reason this failure still passed was due to the fact that the terraform setup action uses a wrapper by default - this wrapper captures stdout, stderr, and exitcode, and exposes those in outputs:

terraform_wrapper - (optional) Whether to install a wrapper to wrap subsequent calls of the terraform binary and expose its STDOUT, STDERR, and exit code as outputs named stdout, stderr, and exitcode respectively. Defaults to true.

As none of those outputs are captured / utilised in this workflow, simplest is to disable the wrapper, and have the normal cli fail -> non zero exit code -> build fails process.

Turn off use of terraform wrapper, and allow the cli to directly return
non-zero exit code.
@wilsonjord wilsonjord force-pushed the fix-terrform-fmt-errors branch from 6d4f124 to c9b4581 Compare February 27, 2026 02:28
@wilsonjord wilsonjord requested a review from jajera February 27, 2026 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant