-
Notifications
You must be signed in to change notification settings - Fork 46
feature request: fail on unexpected exit code #34
Comments
I think you should wrap curl in a shell script that handles that logic? |
But what would I have to do within the shell script to make the module fail then? The The only thing I can think of is ... to kill the terraform process LOL:
I need some way to fail and stop the |
Did we find a resolution to this? I'm facing a similar issue.. with local-exec if the command you execute returns a non-0 exit status it fails the terraform apply which to me feels like the basic expected behavior. I find this module very promising but I"m confused am I missing a feature how do I trigger the module to fail if the command returns an error? |
archiving this project in favor of https://github.com/Invicton-Labs/terraform-external-shell-resource and https://github.com/Invicton-Labs/terraform-external-shell-data |
Hello, thanks for the module!
Would it be possible to add an option to supply an array of "expected" or "ok" exit codes for the command,
and the module would fail and halt terraform when the exit code of the command does not match any of those?
The problem we are facing is that we use the module to make a
curl
request, but the URL we are accessing is not accessible from everywhere - it is internal only. It would be nice to be able to fail the terraform apply in casecurl
returns exit code7
(Failed to connect to host) instead of continuing with an emptystdout
.This is unfortunately related to yet another missing terraform feature, being able to intentionally fail on a condition.
I have tried:
and while this does work initially for the first
apply
(it fails as intended when the API timed out), this empty response still gets written to the remote state (despite me intentionally erroring tf, which I would think taints everything ...) and upon retrying further applys thecurl
command is never executed again it just gets the empty stdout from the remote state and continuously fails/errors on thefile()
statement.So I think embedding the failure condition into your module might be the only sane choice to error-handle this.
Thank you!
The text was updated successfully, but these errors were encountered: