-
Notifications
You must be signed in to change notification settings - Fork 47
This map does not have an element with the key "stdout" #26
Comments
tbh - I don't actually know how my module works internally - so far it just has worked. It relies on terraform "bugs" that I "abuse" in a way. Could you make a github repo with what I could try this out? |
This may be a terraform bug.
When I do a Edit: For now I switched to the external data source as a workaround |
I'm a bit confused - external data sources are run every single time - I built a version of this module with them: https://github.com/matti/terraform-shell-outputs |
I did some troubleshooting with @nitrocode and I think what is happening is this: The module is writing the stdout/stderr to outputs.tf is then checking if the This all works fine in an initial run because |
Ah ok I didn't fully understand the purpose of this module and the difference between
It was explained to me by @lorengordon from the slack chat, that your modules offer a CRUD like approach and show the output in the terraform log whereas the external data source will run every time, like you say, and swallow the output. Anyway, it looks like she has also found out the root issue of what I was seeing. 😄 |
@lorengordon (cc: @nitrocode) I just tested that:
works fine. Can you guys provide me clear steps on how to repro this? |
Are you testing using this project as a module, or directly as the root config? This reproduces when used as a module, slightly modified from the code in the readme:
|
thanks @lorengordon (cc: @nitrocode) - I think this is fixed now in v1.0.4, see a608c3f please re-open if this does not fix it. |
(and not only think but I managed to repro with the instructions. the current tests don't test this, but it the one-off test worked + existing tests passed) |
If you follow @lorengordon steps using
A test for this would be great! |
what would be even better before that is a repro repo so that we have common test ground and not just copy/paste things around. a test for this is very welcome as a PR. I'm investigating this now more. |
https://github.com/matti/repro-terraform-shell-resource-26 here we go, now it's easier to understand |
so the problem might be that the second apply after the delete runs like this:
so it destroys the contents and re-creates it... let's see |
the whole idea of this module is based on my finding that you can store stuff in terraform triggers and now the trigger re-creates because of the the protective I've hit so many roadblocks with this module (reminder, this module only exists because terraform just doesn't do this natively so everything is a massssive hack) that I'm not sure if this is the one where I give up... ...well not give up, but then this module is just intended for use cases where maybe there is a way to restructure the code (again, so that it leaks in some other way then)? |
I can understand the frustration and appreciate you working on this. Alternative solutions
The first method sounds the easiest but the most hackish way. |
I think this is out of scope of this module
If I had the time and patience to do this, I would have done it. Somebody could do it, not me.
Can you explain more?
I've opened about 40 issues in terraform repo(s)... it's kinda.. slow.. |
But I found a way to fix your specific issue, but it breaks apply+apply scenario so that it never updates the output values again from the original ones. see https://github.com/matti/terraform-shell-resource/pull/27/files |
now I think this module needs to start supporting your use case and drop support for multiple applys - it's one off / one way only. changing the commands etc won't change the outputs. cc: @nitrocode |
maybe it can be made dynamic choice - so users can select which behavior they want |
or maybe we could store the outputs twice in two resources and if the files are missing ( |
heey @lorengordon don't laugh, it might work, see updated: https://github.com/matti/terraform-shell-resource/pull/27/files |
(does your brain hurt too?) |
released this as v1.0.5 - it passes apply+apply and @nitrocode case at https://github.com/matti/repro-terraform-shell-resource-26/tree/master passes please make a PR in that repo if this still doesn't work |
This is an interesting thread hashicorp/terraform-provider-external#5 . Idk if I have the ability to do it as a golang noob but it might be fun to try to create the external resource that can solve this once and for all. The guy at the bottom of the thread made https://github.com/toddnni/terraform-provider-shell and that code could be used as a template. I don't know how to solve the issue for this module without some external output or being able to store some input into the tfstate. |
My brain does hurt also. The patch looks suitably hacky, and brilliant in a squinty-sideways kind of way. Quite appropriate! 😂 I do wish terraform would just formalize some way to capture and store shell output. |
so please test, in all my testing it shows that I've deserved a 🍺 |
@matti the test works! nice job! |
Tested, and does survive!
|
travis fails for some reason, it passed locally. no beer. |
what.. if I run the tests in the branch it passes and when it's merged to master it fails. maybe I just delete the master branch and use this one. |
Maybe your branch is out of date with master? Bit me more than once... |
okay it's 02:18am here and I still haven't had that beer. apparently I can not use git anymore (never claimed I did). let's see now.. |
okay so the approach doesn't work for both cases - this hack just postpones the problem (v1.0.5 works because you tested only your case) |
actually tried the sponsor link to send beer 💸 but it says there's a problem parsing the funding.yml file. so sending sad substitute virtual 🍻 instead |
What is it that's not working exactly? I changed the command and re-applied and it re-ran and I got the new output. |
are you using 1.0.5 now? or just released 1.0.6? |
I was testing 1.0.5. Just updated to 1.0.6 and am again getting the same error as in OP. |
because v1.0.5 doesn't pass tests (https://travis-ci.org/matti/terraform-shell-resource/builds/658000605?utm_medium=notification&utm_source=github_status) and v1.0.6 passes, but it fails with https://github.com/matti/repro-terraform-shell-resource-26/tree/master |
hmm, is the apply+apply test faulty |
But you don't get the new output if you don't delete It does run the command, but the output is not updated, because the trigger which stores the contents is not updated. |
@lorengordon @nitrocode please test with v1.0.7 - it seems to support every case combination known to humankind. also have a look at 7fffe89#diff-7a370d8342e7203b805911c92454f0f4R103 implementation. It's crazy, but works. |
You're right! It was a false confirmation. So sorry! v1.0.7 is doing the right thing in all cases! That patch puts us in serious hack territory too. Love it! Much appreciated! 🍺 🍺 🍺 |
Problem
When I apply my terraform module, I get the correct outputs. If I remove my
.terraform
directory and do anotherterraform init && terraform plan
, I get this failure.Error
If I do a
terraform show | less
If I try to do this in the
terraform console
, it won't be able to find this module at all. I did notice that these outputs are not stored in my tfstate. Is that normal?Reproduction steps
terraform-shell-resource
terraform apply
rm -rf .terraform
terraform init
terraform apply
Workaround:
Reference:
The text was updated successfully, but these errors were encountered: