scottwinkler / terraform-provider-shell

Terraform provider for executing shell commands and saving output to state file
Mozilla Public License 2.0
279 stars 60 forks source link

Is it possible to use a returned value in delete #74

Closed dr4Ke closed 3 years ago

dr4Ke commented 3 years ago

I use the create script to create some object. The object is created and assigned an ID in the target system. The script outputs some information about the object, including its internal ID. I would like to use the ID of the created object as the reference for the delete script.

Is there a way to do this?

In fact, I assumed that the object information would be passed, in one way or another, to the delete and update scripts. It seems that it's not.

dr4Ke commented 3 years ago

Related to this, I'm wondering how to use the update script to change the object name, for example. Let's say the object name is given as an environment var, then is changed in the tf file. The update would be triggered but only has the new name in its environment. How do we get the existing object to update it?

Or can we force a delete/create for this context?

dr4Ke commented 3 years ago

OK, I get it. The script is given the current output state in its standard input. So we can compare that to the wanted state and do what we need to.

Sorry for the false issue. I didn't understand it from the documentation, but I see now that it's in all example scripts.