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

adding concatlist for concatenating lists #2113

Closed
wants to merge 1 commit into from

Conversation

lamdor
Copy link
Contributor

@lamdor lamdor commented May 27, 2015

I found myself needing this instead of trying to hack strings together and apart.

The case is this:

variable "a_count" {}
variable "b_count" {}

resource "aws_instance" "a" {
         count = "${var.a_count}"
}

resource "aws_instance" "b" {
         count = "${var.b_count}"
}

resource "aws_instance" "combining-a-b" {
         count = "${var.a_count + var.b_count}"

         provisioner "remote-exec" {
           command = "echo ${element(concatlist(aws_instance.a.*.private_ip, aws_instance.b.*.private_ip), count.index)}"
         }
}

If I want a resource to be created for multiple, but select an element from the total set, it was really difficult. I can see this concatlist being useful for other things as well.

Thoughts?

@knuckolls
Copy link
Contributor

This is significantly cleaner than alternatives he showed me today. Looking forward to seeing this or something like it merged. It solves a need for us when it comes to keeping our tf files DRY but flexible enough to run on multiple "clouds". I can see this being a useful feature for more than just us.

@radeksimko
Copy link
Member

See #1790
Since it's my own PR, I won't close this yet, I will let another maintainer decide here, so I don't look too selfish 😄

@lamdor
Copy link
Contributor Author

lamdor commented May 28, 2015

@radeksimko Perfect. I'll close this and switch our config to yours. I had played around with the idea of just making concat work both ways; glad someone thinks likewise.

@lamdor lamdor closed this May 28, 2015
@lamdor lamdor deleted the concatlist branch May 28, 2015 13:47
@ghost
Copy link

ghost commented May 2, 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 May 2, 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

Successfully merging this pull request may close these issues.

3 participants