You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[`config`](#config) map of arguments or nested blocks
16
16
-[`PROVIDER ARGUMENTS`](#config)
17
-
-[`for_each`](#for_each) map or set of strings | mutually exclusive with `count`
18
17
-[`count`](#count) number | mutually exclusive with `for_each`
18
+
-[`for_each`](#for_each) map or set of strings | mutually exclusive with `count`
19
19
-[`provider`](#provider) reference
20
20
21
21
## Complete configuration
@@ -72,6 +72,18 @@ The `config` block may contain arguments, nested blocks, or a combination of bot
72
72
- Data type: Map of arguments or nested blocks
73
73
- Example: [Define an action](#define-an-action)
74
74
75
+
### `count`
76
+
77
+
The `count` meta-argument instructs Terraform to invoke an action multiple times using the same configuration.
78
+
79
+
```hcl
80
+
resource {
81
+
count = <number>
82
+
}
83
+
```
84
+
85
+
`count` is a **meta-argument**. Meta-arguments are built into the Terraform language and control how Terraform creates resources. Refer to the [`count` reference](/terraform/language/meta-arguments/count) for details about how the argument works.
86
+
75
87
### `for_each`
76
88
77
89
The `for_each` meta-argument instructs Terraform to invoke the action once for each member of a list or key-value pair in a map.
@@ -103,67 +115,7 @@ action "<TYPE>" "<LABEL>" {
103
115
104
116
</Tabs>
105
117
106
-
The `for_each` meta-argument accepts a map or a set of strings and invokes the action once for each item in that map or set. Each invocation is associated with a distinct infrastructure object.
107
-
108
-
You can use pure functions, such as `toset()` and `tomap()`, to create a map or set for use in the `for_each` argument. All values must be known when Terraform plans your action, whether iterating over the keys of a map or set of strings. Otherwise, Terraform prints an error message that `for_each` has dependencies that it cannot determine before applying the configuration.
109
-
110
-
Keys in the `for_each` argument cannot be the result of or rely on the result of impure functions, such as `uuid`, `bcrypt`, or `timestamp`, because Terraform defers evaluating impure functions during the main evaluation step.
111
-
112
-
The `for_each` argument does not implicitly convert lists or tuples to sets. To declare resource instances based on a nested data structure or combinations of elements from multiple data structures, you can use Terraform expressions and functions to derive a suitable value. Refer to the following examples for more information:
113
-
114
-
-[Transform a multi-level nested structure into a flat list](/terraform/language/functions/flatten#flattening-nested-structures-for-for_each).
115
-
-[Combine collections to produce a list of element combinations](/terraform/language/functions/setproduct#finding-combinations-for-for_each).
116
-
117
-
You cannot use sensitive values, such as [sensitive input variables](/terraform/language/block/variable#sensitive), [sensitive outputs](/terraform/language/block/output#sensitive), or [sensitive resource attributes](/terraform/language/expressions/references#sensitive-resource-attributes), as arguments in `for_each`. Because Terraform uses the value in `for_each` to identify the action instance and always discloses it in UI output, sensitive values are not allowed. Terraform returns an error if you attempt to use sensitive values as `for_each` arguments.
118
-
119
-
If you transform a value containing sensitive data into an argument for use in `for_each`, be aware that most functions in Terraform will return a sensitive result if given an argument with sensitive content. In many cases, you can achieve similar results with a `for` expression. For example, to call `keys(local.map)` where `local.map` is an object with sensitive values, but non-sensitive keys, you can create a value to pass to `for_each` using `toset([for k,v in local.map : k])`.
120
-
121
-
Refer to [Manage sensitive data](/terraform/language/manage-sensitive-data) for more information.
122
-
123
-
The `for_each` argument exposes an `each` object that you can reference within the same block to modify specific instances of the action. The object has the following attributes:
124
-
125
-
-`each.key`: Map key or list member that corresponds to an instance.
126
-
-`each.value`: Map value that corresponds to an instance.
127
-
128
-
Use the `<TYPE>.<NAME>[<KEY>]` syntax to access an instance of a resource created using `for_each`. For example, `aws_lambda_invoke.server["a_group"]` refers to an invocation of the `aws_lambda_invoke` action named `server` from a key named `a_group`.
129
-
130
-
The `for_each` argument is a meta-argument, which is built into Terraform and controls the way that Terraform creates resources. Refer to [Meta-arguments](/terraform/language/meta-arguments) for more information.
131
-
132
-
#### Summary
133
-
134
-
- Data type: Map or set of strings.
135
-
- Default: None.
136
-
- Example: [Invoke an action multiple times](#invoke-an-action-multiple-times).
137
-
138
-
### `count`
139
-
140
-
The `count` meta-argument instructs Terraform to invoke an action multiple times using the same configuration.
141
-
142
-
```hcl
143
-
resource {
144
-
count = <number>
145
-
}
146
-
```
147
-
148
-
The value must be a whole number. You can reference variables or local values and use expressions to compute the value, but the value must resolve to a whole number.
149
-
150
-
In blocks where `count` is set, Terraform exposes an additional `count` object. You can reference the object to modify the configuration of each invocation. The `count` object has an `index` attribute starting from `0`.
151
-
152
-
To refer to an individual instance of an invocation using the `count` meta-argument, use the `<TYPE>.<NAME>[INDEX]` syntax. For example, `aws_lambda_invoke.server[0]` refers to the first invocation of the `aws_lambda_invoke` action named `server`.
153
-
154
-
<Tip>
155
-
156
-
You can use the `count` argument as a conditional. For example, setting a `count = var.creator ? 3 : 0` instructs Terraform to invoke an action three times when a variable named `creator` is set to `true`. When `creator` is set to `false`, Terraform does not invoke the action. Refer to [Conditional Expressions](/terraform/language/expressions/conditionals) for more information.
157
-
158
-
</Tip>
159
-
160
-
The `count` argument is a meta-argument, which is built into Terraform and controls the way that Terraform creates resources. Refer to [Meta-arguments](/terraform/language/meta-arguments) for more information.
161
-
162
-
#### Summary
163
-
164
-
- Data type: Number.
165
-
- Default: None.
166
-
- Example: [Invoke an action multiple times](#invoke-an-action-multiple-times).
118
+
`for_each` is a **meta-argument**. Meta-arguments are built into the Terraform language and control how Terraform creates resources. Refer to the [`for_each` reference](/terraform/language/meta-arguments/for_each) for details about how the argument works.
167
119
168
120
### `provider`
169
121
@@ -175,17 +127,7 @@ action "<TYPE>" "<LABEL>" {
175
127
}
176
128
```
177
129
178
-
By default, Terraform automatically selects a provider based on the action type, but you can create multiple provider configurations and use a non-default configuration for specific actions.
179
-
180
-
Use the `<PROVIDER>.<ALIAS>` syntax to reference a provider configuration in the `provider` argument.
181
-
182
-
The `provider` argument is a meta-argument, which is built into Terraform and controls the way that Terraform creates resources. Refer to [Meta-arguments](/terraform/language/meta-arguments) for more information.
183
-
184
-
#### Summary
185
-
186
-
- Data type: Reference.
187
-
- Default: None.
188
-
- Example: [Select an alternate provider configuration](#select-an-alternate-provider-configuration).
130
+
`provider` is a **meta-argument**. Meta-arguments are built into the Terraform language and control how Terraform creates resources. Refer to the [`provider` reference](/terraform/language/meta-arguments/provider) for details about how the argument works.
Copy file name to clipboardExpand all lines: content/terraform/v1.14.x (beta)/docs/language/block/check.mdx
+3-18Lines changed: 3 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -122,7 +122,7 @@ The arguments within a `data` block are provider-specific. Refer to the [registr
122
122
123
123
### `depends_on`
124
124
125
-
The `depends_on` argument specifies an upstream resource that the `data` block depends on. Terraform must complete all operations on the upstream resource before fetching information from the `data` block.
125
+
The `depends_on` argument specifies an upstream resource that the `data` block depends on. Terraform must complete all operations on the upstream resource before fetching information from the `data` block.
126
126
127
127
```hcl
128
128
check "unique_name" {
@@ -135,13 +135,7 @@ check "unique_name" {
135
135
}
136
136
```
137
137
138
-
We recommend adding the `depends_on` argument if your nested data source depends on another resource without referencing that resource directly.
139
-
140
-
For example, if you define a `check` that verifies that a website API returns `200`, that check fails the first time Terraform runs your configuration because your website's infrastructure does not exist yet. You can set the `depends_on` argument to a resource, such as the load balancer, to ensure Terraform only runs the `check` once the website is up. When running an operation, Terraform evaluates the `check`, warns `known after apply` until that crucial piece of your website is ready, and continues the operation.
141
-
142
-
However, this strategy only works when the `data` block does not directly reference the resource specified in the `depends_on` argument. Otherwise, anytime that resource changes, the `check` block warns `known after apply` until Terraform updates that resource, making your check potentially noisy and ineffective. Refer to the [example](#resource-dependency) for more details.
143
-
144
-
The `depends_on` block is a meta-argument. Meta-arguments are built-in arguments that control how Terraform creates resources. Refer to [Meta-arguments](/terraform/language/meta-arguments) for additional information.
138
+
`depends_on` is a **meta-argument**. Meta-arguments are built into the Terraform language and control how Terraform creates resources. Refer to the [`depends_on` reference](/terraform/language/meta-arguments/depends_on) for details about how the argument works.
145
139
146
140
### `provider`
147
141
@@ -158,16 +152,7 @@ check "unique_name" {
158
152
}
159
153
```
160
154
161
-
By default, Terraform automatically selects a provider based on the nested data source's type, but you can create multiple provider configurations and use a non-default configuration for specific data sources.
162
-
163
-
The `provider` argument is a meta-argument, which is built into Terraform and controls the way that Terraform creates resources. Refer to [Meta-arguments](/terraform/language/meta-arguments) for additional information.
164
-
165
-
#### Summary
166
-
167
-
- Data type: Block.
168
-
- Default: None.
169
-
- Supported meta-arguments: `depends_on` and `provider`.
`provider` is a **meta-argument**. Meta-arguments are built into the Terraform language and control how Terraform creates resources. Refer to the [`provider` reference](/terraform/language/meta-arguments/provider) for details about how the argument works.
0 commit comments