Skip to content

Instantly share code, notes, and snippets.

@kamatama41
Last active May 18, 2016 03:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kamatama41/c9e32a3c2033c21f3e2a059c3b6c8422 to your computer and use it in GitHub Desktop.
Save kamatama41/c9e32a3c2033c21f3e2a059c3b6c8422 to your computer and use it in GitHub Desktop.
I'd like to do the following foreach syntax at Terraform to reduce code amount...
["http", "https"].each do |protocol|
resource "aws_security_group_rule" "allow_${protocol}" {
security_group_id = "${aws_security_group.foo.id}"
type = "ingress"
from_port = ${protocol == "http" ? 80 : 443}
to_port = ${protocol == "http" ? 80 : 443}
protocol = "${protocol}"
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment