Skip to content
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

Closed
mrwilby opened this issue Aug 11, 2016 · 5 comments
Closed

Feature request - null_resource + local_exec + get output as variable #8136

mrwilby opened this issue Aug 11, 2016 · 5 comments

Comments

@mrwilby
Copy link

mrwilby commented Aug 11, 2016

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.

@apparentlymart
Copy link
Contributor

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.

@mrwilby
Copy link
Author

mrwilby commented Aug 11, 2016

@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!

@mrwilby mrwilby closed this as completed Aug 11, 2016
@matti
Copy link

matti commented Feb 14, 2018

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

@matti
Copy link

matti commented Feb 9, 2020

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

@ghost
Copy link

ghost commented Feb 10, 2020

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.

@ghost ghost locked and limited conversation to collaborators Feb 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants