LoginSignup
0
0

More than 1 year has passed since last update.

Terraformでdynamicを活用して複数×複数のブロックを書く

Last updated at Posted at 2022-07-14
  • 配列になっている変数を複数行並べる
  • dynamicブロックの中でfor_eachを活用し、行数分ブロックが作成される
  • 複数ブロックの中の値はeach.valueの要素番号で取得する

locals {
  Setting = {
    custom_error_response = {
      res-403-403 = [10, 403, 403, "/error-403.html"],
      res-502-502 = [10, 502, 502, "/error-502.html"]
    }
  }
}

resource "aws_cloudfront_distribution" "cdn" {
  dynamic "custom_error_response" {
    for_each = Setting.custom_error_response
    content {
      error_caching_min_ttl = custom_error_response.value[0]
      error_code            = custom_error_response.value[1]
      response_code         = custom_error_response.value[2]
      response_page_path    = custom_error_response.value[3]
    }
  }
}
0
0
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
0
0