Terraform 有两种方法可以做到这一点:count和for_each。 如果一个资源或模块块包括一个for_each参数,其值是一个 map 或字符串集合,Terraform 为该 map 或字符串集合的每个成员创建一个实例。 版本说明:for_each是在 Terraform 0.12.6 中添加的。Terraform 0.13 中增加了对for_each的模块支持;以前的版本只能在资源...
"jaeger_url":"http://dev-jaeger.example.com"},{"env_name":"test","prom_url":"http://test-prom.example.com","es_url":"http://test-es.example.com:9200","jaeger_url":"http://test-jaeger.example.com"}]
这个for表达式遍历了var.list中的每个元素,然后评估表达式upper(s),将s设置为每个相应的元素。然后它用所有执行该表达式的结果按相同的顺序建立一个新的元组值。 一个for表达式的输入(在in关键字之后给出)可以是一个列表,一个集合,一个元组,一个 map,或者一个对象 (object)。
如需根据内嵌数据结构或者多个数据结构的元素组合来声明资源实例集合,可使用 Terraform 表达式和函数来生成合适的值。 iterator变量(上述示例中的 setting)具备以下属性: key:若迭代容器是 map,则 key 为当前元素的键。若迭代容器是 list,则 key 为当前元素在 list 中的下标序号。若是由 for_each 表达式产出的 set...
Terraform 0.12 introduces a new construct called a for expression, which allows the construction of a list or map by transforming and filtering elements in another list or map. The example below shows this in use: # Configuration for Terraform 0.12variable"vpc_id"{description="ID for the AWS ...
for 表达式 一个for表达式通过转换另一个复杂类型的值来创建一个复杂类型的值。输入值中的每个元素可以对应于结果中的一个或零个值,并且可以使用一个任意的表达式来将每个输入元素转化为输出元素。 例如,如果var.list是一个字符串的列表,那么下面的表达式将产生一个全大写字母的字符串的元组: 代码语言:javascript 复...
Terraform 0.12 introduces a new construct called a for expression, which allows the construction of a list or map by transforming and filtering elements in another list or map. The example below shows this in use: # Configuration for Terraform 0.12 ...
alarm_actions- (Required) The list of actions to execute when this alarm transition into an ALARM state. Each action is specified as ess scaling rule ari. scaling_group_id- (Required, ForceNew) The scaling group associated with this alarm, the 'ForceNew' attribute is available in 1.56.0+...
`example_name`" default = "" } variable "vswitch_ids" { description = "List of existing vswitch id." type = list(string) default = [] } variable "vswitch_cidrs" { description = "List of cidr blocks used to create several new vswitches when 'vswitch_ids' is not specified." type ...
example of my setup: resource "google_bigquery_table" "bigquery-view" { for_each = { for idx, record in local.bigquery_views_list : record["view"] => record } depends_on = [for x in each.value.depends_on : google_bigquery_table.bigquery-view[x]] dataset_id = each.value.dataset ...