-
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
Request: Custom Outputs from null_resource/local-exec #6830
Comments
Hi @qivers! It's not possible to do this using null-resource, but the development branch of Terraform 0.7 (on |
Hi, @jen20, I'm not able to see how v0.7.0 can fix this issue. This is required essentially for me as I'm using a script to get the private_ips of resources created by auto-scaling group. I need to pass this information to another TF module. So, I need to output this. Is there any way, I can acheive this? |
Could @jen20 @apparentlymart explain how to use the new "data sources" feature to run a local script and get the output as a terraform variable? TIA! |
We don't (yet) have a data source for running a local command, but for the specific use-case given here (finding an existing AMI) we have |
@apparentlymart Yup, like I thought. As far as I think, there is no direct way for this except some hack with |
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 |
Update, now the module works also with remote state setups with an insane trick where I store the outputs in null_resource triggers and then ignore lifecycle changes for the triggers (!) https://github.com/matti/terraform-shell-resource/blob/master/main.tf#L58-L67 |
Just revisited the solution mentioned above - managed to drop the requirement for external data source (ruby) now. |
Will this module find it's way into the core someday? |
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. |
Hi
I had a quick search but I couldn't find a feature request for this so apologies if it's a duplicate.
I was wondering if it would be possible to create custom outputs, from a null_resource, running a script in a local-exec?
Our current use case is that we are building custom AMIs. We would like to pass the AMI ID to our Terraform aws_instance and aws_launch_configuration resources without manually updating a variable in tfvars.
So the idea is, we'd have a null_resource with a local-exec which would pull in the latest AMI IDs using a script, and then we could assign the AMI ID outputted from that script to a terraform output;
This script would return the latest debian AMI ID which could then be ingested like any other module output;
I realise this might be difficult but wondered if it was something worth considering?
Cheers.
The text was updated successfully, but these errors were encountered: