我有下一个清单:
local {
...
step_scaling_out_policy_configuration = {
"adjustment_type" = "ChangeInCapacity"
"cooldown" = 300
"metric_aggregation_type" = "Maximum"
"step_adjustment" = {
"metric_interval_lower_bound" = 0
"scaling_adjustment" = 1
}
}
...
}
我可以使用下一个逻辑转换成块:
step_scaling_policy_configuration {
adjustment_type = local.step_scaling_out_policy_configuration.adjustment_type
cooldown = local.step_scaling_out_policy_configuration.cooldown
metric_aggregation_type = local.step_scaling_out_policy_configuration.metric_aggregation_type
step_adjustment {
metric_interval_lower_bound = local.step_scaling_out_policy_configuration.step_adjustment.metric_interval_lower_bound
scaling_adjustment = local.step_scaling_out_policy_configuration.step_adjustment.scaling_adjustment
}
}
在地图中使用固定数量的键非常容易。但是是否可以动态生成这样的块,因为我不知道local.step_scaling_out_policy_configuration
地图中到底有什么。现在假设我有
local {
...
step_scaling_out_policy_configuration = {
"adjustment_type" = "ChangeInCapacity"
"cooldown" = 300
"metric_aggregation_type" = "Maximum"
#######
"some_new_key" = "value"
#######
"step_adjustment" = {
"metric_interval_lower_bound" = 0
"scaling_adjustment" = 1
}
}
...
}
显然,按照以前的逻辑,我不会在块中有some_new_key
参数。是否可以根据地图内部的内容动态step_scaling_policy_configuration
添加键来阻止?step_scaling_policy_configuration
local.step_scaling_out_policy_configuration