terraform-provider-shell icon indicating copy to clipboard operation
terraform-provider-shell copied to clipboard

add an error_tag optional field to resource.shell_script

Open mrzor opened this issue 4 years ago • 1 comments

This is a hack that fixes #60.

I believe the footprint to be reasonably small and that it has some merit.

I'm tempted to use a DiffSuppressFunc that disables the diff entirely for this field, hoping to trigger no changes at all when adding an error_tag or changing it - but that may be counter-intuitive ; and it would take some explaining - so I refrained.

The biggest downside is that it's not very Terraformish. Maybe the real solution for #60 should be within Terraform itself.

The tests pass and I added an extra one, but I'm in no way sure that I did not break anything.

Feel free to close if you believe this fix is too much of a burden to maintain or ill designed.

mrzor avatar Jul 26 '20 13:07 mrzor

I think this could be a good idea except i would like to see it combined with the retry block from earlier. For example, I could see something like:

	resource "shell_script" "basic" {
		lifecycle_commands {
		  create = <<EOF
		    echo "Something went wrong!"
			exit 1
EOF
		  delete = "exit 1"
		}
		environment = {
		  filename= "create_delete.json"
		}
                on_error = {
                  tag = var.username
                  retry = {
                       exit_code = 30
                       delay = 5
                  }
                }
	  }
)

scottwinkler avatar Jul 27 '20 04:07 scottwinkler