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
-[`count`](#count) number   | mutually exclusive with `for_each`
18
18
-[`for_each`](#for_each)   map or set of strings | mutually exclusive with `count`
19
-
-[`depends_on`](#depends_on)   list of references
20
19
-[`include_resource`](#include_resource) boolean
21
20
-[`limit`](#limit) number | `100`
22
21
-[`config`](#config) block
@@ -33,7 +32,6 @@ list "<TYPE>" "<LABEL>" {
33
32
for_each [ # `for_each` and `count` are mutually exclusive
34
33
<KEY> = <VALUE>
35
34
]
36
-
depends_on = [ <RESOURCE.ADDRESS.EXPRESSION> ]
37
35
include_resource = <false>
38
36
limit = 100
39
37
config {
@@ -90,7 +88,7 @@ The value must be a whole number. You can reference variables or local values an
90
88
91
89
In blocks where `count` is set, Terraform exposes an additional `count` object. You can reference the object to modify the configuration of each list of query results. The `count` object has an `index` attribute starting from `0`.
92
90
93
-
To refer to an individual list of query results, use the `<TYPE>.<NAME>[INDEX]` syntax. For example, `aws_instance.server[0]` refers to the first list of query results for the `aws_instance` resource named `server`.
91
+
To refer to an individual list of query results, use the `list.<TYPE>.<NAME>[INDEX]` syntax. For example, `list.aws_instance.server[0]` refers to the first list of query results for the `aws_instance` resource named `server`.
94
92
95
93
<Tip>
96
94
@@ -106,31 +104,6 @@ The `count` argument is a meta-argument, which is built into Terraform and contr
106
104
- Default: None.
107
105
- Example: [Create multiple lists of query results](#create-multiple-lists-of-query-results).
108
106
109
-
### `depends_on`
110
-
111
-
The `depends_on` meta-argument specifies an upstream resource that the `list` block depends on. Terraform must complete all operations on the upstream resource before performing operations on the `list` block containing the `depends_on` argument.
112
-
113
-
```hcl
114
-
list "<TYPE>" "<LABEL>" {
115
-
depends_on = [ <reference resource> ]
116
-
}
117
-
```
118
-
119
-
When a query configuration refers to another resource, Terraform identifies the dependency and creates the upstream resource first. In some cases, you may need Terraform to create a resource before creating a list of query results, even though the objects are configured independently.
120
-
121
-
Use the `depends_on` argument when the objects do not reference each other. We recommend always including a comment to explain resource dependencies when using a `depends_on` argument.
122
-
123
-
When using the `depends_on` meta-argument, you can only reference resources or child modules in the same root module. The list cannot include arbitrary expressions. Any values referenced in the `depends_on` list must be known before Terraform begins the operation so that it can evaluate dependencies.
124
-
125
-
Specifying an entire module in the `depends_on` argument affects the order in which Terraform provisions all of the resources and data sources associated with that module. Refer to [Resource dependencies](/terraform/language/resources/configure#specify-resource-dependencies) and [Data resource dependencies](/terraform/language/data-sources#dependencies) for more information.
126
-
127
-
The `depends_on` 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.
128
-
129
-
#### Summary
130
-
131
-
- Data type: List.
132
-
- Default: None.
133
-
134
107
### `for_each`
135
108
136
109
The `for_each` meta-argument instructs Terraform to create similar lists of query results without requiring separate configuration blocks for each list.
@@ -184,7 +157,7 @@ The `for_each` argument exposes an `each` object that you can reference within t
184
157
-`each.key`: Map key or list member that corresponds to list.
185
158
-`each.value`: Map value that corresponds to a list.
186
159
187
-
Use the `<TYPE>.<NAME>[<KEY>]` syntax to access an instance of a resource created using `for_each`. For example, `azurerm_resource_group.rg["a_group"]` refers to a list of query results for the `azurrm_resource_group` resource named `rg` created from the `a_group` key.
160
+
Use the `list.<TYPE>.<NAME>[<KEY>]` syntax to access an instance of a resource created using `for_each`. For example, `list.azurerm_resource_group.rg["a_group"]` refers to a list of query results for the `azurrm_resource_group` resource named `rg` created from the `a_group` key.
188
161
189
162
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.
In the following example, the `include_resource` argument is set to `true` in the `list.concept_pet.animals_with_legs` block. As a result, the query returns complete resource state information to the list of results for `animals_with_legs`. This lets the `list.concept_pet.more_pets` block reference the `length` attribute from `animals_with_legs` as the value for its `count` argument.
Copy file name to clipboardExpand all lines: content/terraform/v1.14.x (alpha)/docs/language/import/bulk.mdx
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,9 +14,10 @@ For organizations with large sets of infrastructure resources, manually identify
14
14
Complete the following steps to find and import resources in bulk:
15
15
16
16
- Search for resources: Create `list` blocks to search for existing resources.
17
-
- Generate configuration: Use the Terraform command to generate `resource` and `import` blocks for importing the resources. The configuration also includes the resource ID.
17
+
- Generate configuration: Use the Terraform command to generate `resource` and `import` blocks for importing the resources. The configuration also includes the [resource identity](#resource-identity).
@@ -62,7 +63,7 @@ Add the following arguments to your `list` block:
62
63
63
64
-`include_resource`: By default, Terraform retrieves only resource identities, but you can set the `include_resource` argument to `true` so that Terraform can also retrieve all available resource attributes. To reference resource attributes retrieved by the list block, you must enable the `include_resource` argument. Setting this argument to `true` may affect performance.
64
65
65
-
-`limit`: By default, Terraform retrieves up to 100 resources per query, but you can use the `limit` argument to specify a higher or lower number of results.
66
+
-`limit`: By default, Terraform retrieves up to 100 resources per list block, but you can use the `limit` argument to specify a higher or lower number of results.
66
67
67
68
The `list` block also supports several Terraform **meta-arguments**, which are arguments built into Terraform configuration language that configure how Terraform creates and manages infrastructure objects. For example, you can use the `count` meta-argument to create multiple instances of the resource list returned by the query. Refer to [Meta-arguments](/terraform/language/meta-arguments) for more information.
Copy file name to clipboardExpand all lines: content/terraform/v1.14.x (alpha)/docs/language/import/index.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,4 +21,4 @@ When you need to identify and import large sets of infrastructure resources, you
21
21
22
22
The workflow for importing single resources or small batches of resources works best when you can easily access unique infrastructure resource IDs and other attributes from your cloud provider. In this workflow, manually write `import` and `resource` blocks and run the `terraform apply` command to import the resources.
23
23
24
-
Alternatively, you can write only the `import` block and run the `terraform apply` command with the `generate-config` flag to generate the `resource` blocks. Refer to [Import a single resource](/terraform/language/import/single-resource) for more information.
24
+
Alternatively, you can write only the `import` block and run the `terraform plan` command with the `generate-config-out` flag to generate the `resource` blocks. Refer to [Import a single resource](/terraform/language/import/single-resource) for more information.
0 commit comments