3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[WIP]terraformのdynamic blocksを用いたresourceの記述例と参考リンク

Last updated at Posted at 2019-08-04

概要

dynamic blocksを用いたresourceの記述例と参考リンク
terraform初心者の自分為のdynamic blocksの書き方メモ
時間がある際に追記します

開発環境

  • OSX Mojave 10.14.4
  • terraform 0.12.5

dynamic blocks参考資料リンク

記述例

  • aws_autoscaling_policyのstep_adjustment
variable "asg_steps" {
  type = list(map(string))
  default = [
   {
     scaling_adjustment           = 1
     metric_interval_lower_bound  = 1
     metric_interval_upper_bound  = 1000
   },
   {
     scaling_adjustment           = 2
     metric_interval_lower_bound  = 1000
     metric_interval_upper_bound  = 2000
   },
   {
     scaling_adjustment           = 3
     metric_interval_lower_bound  = 2000
     metric_interval_upper_bound  = null
   },
  ]
}

resource "aws_autoscaling_policy" "asg_policy" {
  name                   = "auto scaling grouop policy"
  adjustment_type        = "ExactCapacity"
  autoscaling_group_name = aws_autoscaling_group.ecs_asg.name
  policy_type = "StepScaling"

  dynamic "step_adjustment" {
    for_each = var.asg_steps
    content {
      scaling_adjustment          = step_adjustment.value["scaling_adjustment"]
      metric_interval_lower_bound = step_adjustment.value["metric_interval_lower_bound"]
      metric_interval_upper_bound = step_adjustment.value["metric_interval_upper_bound"]
    }
  }
}

スキップする項目(metric_interval_upper_bound)は代入値を'null'にすることで書式を合わせてます

3
2
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
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?