-
Notifications
You must be signed in to change notification settings - Fork 62
Open
Description
We've found an issue with TF tracking changes to the script when there aren't any and after it has been successfully applied.
After some investigation, we concluded that this is due to the output that the shell_script
resource is producing and that:
- you can echo whatever you want in a script
- shell provider will only look at the final non-empty thing you echo from a script and use this as the output
- that final echo must be valid JSON, otherwise it ignores it and will record the script output as null
- also weirdly, only the final part of that final echo needs to be valid JSON (i.e. you can do echo 'blah blah blah
{"is_json": "true"}'
and it will magically extract{"is_json": "true"}
as the output - if output is null, will always say the resource needs to be created
- if output is empty and there's a change, it will say it needs to be created (not changed)
- if you output nothing in the create function, it will take the output from the read function during an apply
The simplest solution we found is to have final statement in the read function with an echo in JSON format, e.g.:
function read {
echo "Running the shell script READ operation...";
echo "Nothing to do";
echo '{"read": "OK"}';
return 0;
}
Can some documentation about this be added to the provider please? Thank you.
Metadata
Metadata
Assignees
Labels
No labels