LoginSignup
3
3

More than 5 years have passed since last update.

Terraformでiterationを利用して冗長な記述をなくす ver. 0.7 ~

Posted at
  • variables.tf
variable "roles" {
    type    = "list"
    default = ["foo", "bar"]
}
  • elb.tf
resource "aws_elb" "roles-elb" {
    count = "${length(var.roles)}"
    name  = "${var.roles[count.index]}-elb"
   ... 
}

のようにcountをlistのlengthで渡して利用時にfoo[count.index]で利用する。
これで冗長な設定を記述しなくてすむので便利。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3