Skip to content

Commit 7a29850

Browse files
committed
forport meta-args topics to 1.14 core - TODO stacks
1 parent c940b65 commit 7a29850

File tree

19 files changed

+1369
-1034
lines changed

19 files changed

+1369
-1034
lines changed

content/terraform/v1.14.x (beta)/data/language-nav-data.json

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,37 @@
389389
},
390390
{
391391
"title": "Meta-arguments",
392-
"path": "meta-arguments"
392+
"routes": [
393+
{
394+
"title": "Overview",
395+
"path": "meta-arguments",
396+
"alias": "actions"
397+
},
398+
{
399+
"title": "count",
400+
"path": "meta-arguments/count"
401+
},
402+
{
403+
"title": "depends_on",
404+
"path": "meta-arguments/depends_on"
405+
},
406+
{
407+
"title": "for_each",
408+
"path": "meta-arguments/for_each"
409+
},
410+
{
411+
"title": "lifecycle",
412+
"path": "meta-arguments/lifecycle"
413+
},
414+
{
415+
"title": "provider",
416+
"path": "meta-arguments/provider"
417+
},
418+
{
419+
"title": "providers",
420+
"path": "meta-arguments/providers"
421+
}
422+
]
393423
},
394424
{
395425
"title": "Built-in resources",

content/terraform/v1.14.x (beta)/docs/language/block/action.mdx

Lines changed: 15 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ The `action` block supports the following configuration:
1414
- [`action "<TYPE>" "<LABEL>"`](#action) &nbsp block
1515
- [`config`](#config) &nbsp; map of arguments or nested blocks
1616
- [`PROVIDER ARGUMENTS`](#config)
17-
- [`for_each`](#for_each) &nbsp; map or set of strings | mutually exclusive with `count`
1817
- [`count`](#count) &nbsp; number | mutually exclusive with `for_each`
18+
- [`for_each`](#for_each) &nbsp; map or set of strings | mutually exclusive with `count`
1919
- [`provider`](#provider) &nbsp; reference
2020

2121
## Complete configuration
@@ -72,6 +72,18 @@ The `config` block may contain arguments, nested blocks, or a combination of bot
7272
- Data type: Map of arguments or nested blocks
7373
- Example: [Define an action](#define-an-action)
7474

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+
7587
### `for_each`
7688

7789
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>" {
103115

104116
</Tabs>
105117

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.
167119

168120
### `provider`
169121

@@ -175,17 +127,7 @@ action "<TYPE>" "<LABEL>" {
175127
}
176128
```
177129

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.
189131

190132
## Examples
191133

content/terraform/v1.14.x (beta)/docs/language/block/check.mdx

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ The arguments within a `data` block are provider-specific. Refer to the [registr
122122

123123
### `depends_on`
124124

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.
126126

127127
```hcl
128128
check "unique_name" {
@@ -135,13 +135,7 @@ check "unique_name" {
135135
}
136136
```
137137

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.
145139

146140
### `provider`
147141

@@ -158,16 +152,7 @@ check "unique_name" {
158152
}
159153
```
160154

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`.
170-
- Example: [Resource dependency](#resource-dependency).
155+
`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.
171156

172157
## Examples
173158

0 commit comments

Comments
 (0)