-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request - null_resource + local_exec + get output as variable #8136
Comments
Sorry I didn't spot this issue before I started writing my own... I have a proposal over in #8144 that I think speaks to what you're describing here, though perhaps in a more elaborate way than what you were proposing. |
@apparentlymart Your proposal is indeed great! Would work for all our use cases and I agree it's much more elegant than local_exec (which is definitely a workaround for missing higher-level abstractions). Love it! |
External data sources get run every time - if you just want to get output once, I made a module for this https://github.com/matti/terraform-shell-resource |
https://github.com/matti/terraform-shell-resource has been updated so that it updates the outputs if command changes and does not run on every apply |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
See some discussion here: #6830
The basic idea is to have a way (possibly, a "data source") that can execute a local provisioner command and receive the output (stdout, stderr) as a variable that can be referenced by downstream dependencies in the DAG.
I have tried to work around this by redirecting a null_resource's local_exec output to file. We then reference this file using the file(..) interpolation syntax.
However, in our system we don't want to check this (transient) file into source control as all our remote state is externalized (via the S3 feature). This means that the first time terraform plan is executed, the transient file does not exist and in turn, terraform fails to plan.
It's a similar case for destroy - if the file doesn't exist then destroy fails.
I think using variables/dynamically wiring the graph would be better than hackery with files, but as said, I don't think this is supported yet.
The text was updated successfully, but these errors were encountered: