{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/1812","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/1812/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/1812/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/1812/events","html_url":"https://github.com/hashicorp/terraform/issues/1812","id":73388039,"number":1812,"title":"config: Add joinf function?","user":{"login":"radeksimko","id":287584,"avatar_url":"https://avatars.githubusercontent.com/u/287584?v=3","gravatar_id":"","url":"https://api.github.com/users/radeksimko","html_url":"https://github.com/radeksimko","followers_url":"https://api.github.com/users/radeksimko/followers","following_url":"https://api.github.com/users/radeksimko/following{/other_user}","gists_url":"https://api.github.com/users/radeksimko/gists{/gist_id}","starred_url":"https://api.github.com/users/radeksimko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radeksimko/subscriptions","organizations_url":"https://api.github.com/users/radeksimko/orgs","repos_url":"https://api.github.com/users/radeksimko/repos","events_url":"https://api.github.com/users/radeksimko/events{/privacy}","received_events_url":"https://api.github.com/users/radeksimko/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hashicorp/terraform/labels/core","name":"core","color":"cccccc"},{"url":"https://api.github.com/repos/hashicorp/terraform/labels/enhancement","name":"enhancement","color":"d4c5f9"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-05T18:17:49Z","updated_at":"2015-05-13T07:25:57Z","closed_at":"2015-05-13T07:25:57Z","body":"I caught myself writing the following code I don't like at all:\r\n\r\n```ruby\r\nresource \"aws_instance\" \"worker\" {\r\n  ami = \"${lookup(var.aws_coreos_ami, var.aws_region)}\"\r\n  instance_type = \"m3.medium\"\r\n  availability_zone = \"${var.aws_az_name}\"\r\n\r\n  user_data = <<USER_DATA\r\n#cloud-config\r\ncoreos:\r\n  flannel:\r\n    etcd_endpoints: http://${aws_instance.etcd.0.private_ip}:4001,http://${aws_instance.etcd.1.private_ip}:4001,http://${aws_instance.etcd.2.private_ip}:4001\r\nUSER_DATA\r\n}\r\n```\r\n\r\nSee the list of etcd endpoints which is not scalable at all, just because I have to provide a list of IPs with protocol + port number.\r\n\r\nSo I was thinking this could be much easier and scalable with hypothetical function `joinf` (name coming from `join` + `format`):\r\n\r\n```ruby\r\nresource \"aws_instance\" \"worker\" {\r\n  ami = \"${lookup(var.aws_coreos_ami, var.aws_region)}\"\r\n  instance_type = \"m3.medium\"\r\n  availability_zone = \"${var.aws_az_name}\"\r\n\r\n  user_data = <<USER_DATA\r\n#cloud-config\r\ncoreos:\r\n  flannel:\r\n    etcd_endpoints: ${joinf(\",\", \"http://%s:4001\", aws_instance.etcd.*.private_ip)}\r\nUSER_DATA\r\n}\r\n```\r\n\r\nAny ideas for better name / reservations? I may send a PR at some point, but it would be nice to have a few :+1: or :-1: (+ reasons ideally)."},"comment":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/comments/101546424","html_url":"https://github.com/hashicorp/terraform/issues/1812#issuecomment-101546424","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/1812","id":101546424,"user":{"login":"radeksimko","id":287584,"avatar_url":"https://avatars.githubusercontent.com/u/287584?v=3","gravatar_id":"","url":"https://api.github.com/users/radeksimko","html_url":"https://github.com/radeksimko","followers_url":"https://api.github.com/users/radeksimko/followers","following_url":"https://api.github.com/users/radeksimko/following{/other_user}","gists_url":"https://api.github.com/users/radeksimko/gists{/gist_id}","starred_url":"https://api.github.com/users/radeksimko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radeksimko/subscriptions","organizations_url":"https://api.github.com/users/radeksimko/orgs","repos_url":"https://api.github.com/users/radeksimko/repos","events_url":"https://api.github.com/users/radeksimko/events{/privacy}","received_events_url":"https://api.github.com/users/radeksimko/received_events","type":"User","site_admin":false},"created_at":"2015-05-13T07:25:57Z","updated_at":"2015-05-13T07:25:57Z","body":"This can be now done using a new function [`formatlist`](https://github.com/hashicorp/terraform/pull/1829):\r\n\r\n```\r\n${join(\",\", formatlist(\"http://%s:4001\", aws_instance.etcd.*.private_ip))}\r\n```\r\n\r\nI'm gonna close this as the above approach feels a bit cleaner than having one function that does two things (`join` + `formatlist`).\r\n\r\nThanks @josharian for making it happen! :smiley_cat: "}}