-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
config: add select function #4011
Conversation
Hi @thegedge! Thanks for submitting this PR. I think if we're going to merge this, we need to consider how it might evolve in the future with respects to syntax. @phinze, @mitchellh and @catsby, do you have any thoughts on this? |
I should mention that a combination of the following issues would probably give the same result:
With those two you could perhaps do something like this:
Note that this example doesn't make use of #2727, but it would be something we'd need. |
@phinze, @mitchellh this is ready for your 👀, has tests, doc & passes |
The implementation here looks good! But I'm a little worried about potential "flag sprawl" by adding this feature. Picturing possible ways you might want to filter I'm thinking it might be a better strategy to try to address (a) Add a JSON output format to In order to do filtering equivalent to this, you'd need something more like (a). |
@phinze Any any thoughts on this PR? Are there things in the pipeline to make this PR unnecessary? It's been lying around for quite some time, so I'd like to either get it merged or close it off 😃 |
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. |
There's a lot of activity in #1604, so conditional behaviour built into terraform core appears to be a much-desired request. In one of my comments in that thread I showed a way to evaluate a ternary –
if foo == "spam" then bar else baz
– usingreplace
:Not a pretty beast, but we've been writing it. We were going to create a module to compute this for us, but feel that a module was too much, so I thought I'd propose this
select
function (note: feel free to propose a better name), as a way to avoid writing the nasty expression above. Some use cases for us:aws_instance
. If we decide to place it in a private subnet then we need to make sure the connection goes through a bastion and uses the private ip. We use a ternary to do this.