Skip to content

Commit df295f9

Browse files
committed
feedback from draft reviews
1 parent b1841cf commit df295f9

File tree

5 files changed

+32
-36
lines changed

5 files changed

+32
-36
lines changed

content/terraform/v1.14.x (alpha)/docs/cli/commands/query.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ The following command loads variable values defined in `my-vars.tfvars`:
7171
$ terraform query -var-file=my-vars.tfvars
7272
```
7373

74-
### Generate inport configuration
74+
### Generate import configuration
7575

7676
The following command generates `import` and `resource` blocks for the query results to a file in the `/to-import` directory:
7777

7878
```shell-session
79-
$ terraform query -generate-config=to-import
79+
$ terraform query -generate-config=to-import/file.tf
8080
```
8181

8282
The following command prints `import` and `resource` blocks for the query results as json:

content/terraform/v1.14.x (alpha)/docs/language/block/tfquery/list.mdx

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ A `list` block supports the following configuration:
1616
- [`provider`](#provider) &nbsp reference | required
1717
- [`count`](#count) number &nbsp | mutually exclusive with `for_each`
1818
- [`for_each`](#for_each) &nbsp map or set of strings | mutually exclusive with `count`
19-
- [`depends_on`](#depends_on) &nbsp list of references
2019
- [`include_resource`](#include_resource) boolean
2120
- [`limit`](#limit) number | `100`
2221
- [`config`](#config) block
@@ -33,7 +32,6 @@ list "<TYPE>" "<LABEL>" {
3332
for_each [ # `for_each` and `count` are mutually exclusive
3433
<KEY> = <VALUE>
3534
]
36-
depends_on = [ <RESOURCE.ADDRESS.EXPRESSION> ]
3735
include_resource = <false>
3836
limit = 100
3937
config {
@@ -90,7 +88,7 @@ The value must be a whole number. You can reference variables or local values an
9088

9189
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`.
9290

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`.
9492

9593
<Tip>
9694

@@ -106,31 +104,6 @@ The `count` argument is a meta-argument, which is built into Terraform and contr
106104
- Default: None.
107105
- Example: [Create multiple lists of query results](#create-multiple-lists-of-query-results).
108106

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-
134107
### `for_each`
135108

136109
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
184157
- `each.key`: Map key or list member that corresponds to list.
185158
- `each.value`: Map value that corresponds to a list.
186159

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

189162
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.
190163

@@ -322,4 +295,23 @@ resource "aws_iam_user" "the-accounts" {
322295

323296
</Tab>
324297

325-
</Tabs>
298+
</Tabs>
299+
300+
### Reference a list block
301+
302+
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.
303+
304+
```hcl
305+
list "concept_pet" "animals_with_legs" {
306+
provider = concept
307+
include_resource = true
308+
}
309+
310+
list "concept_pet" "more_pets" {
311+
provider = concept
312+
313+
config {
314+
count = list.concept_pet.animals_with_legs.data[0].state.length
315+
}
316+
}
317+
```

content/terraform/v1.14.x (alpha)/docs/language/import/bulk.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ For organizations with large sets of infrastructure resources, manually identify
1414
Complete the following steps to find and import resources in bulk:
1515

1616
- 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).
18+
1819
- Import resources: Copy the generated configuration into your main.tf file and run a `terraform apply` command to import the resources.
19-
- After importing resources, you can remove the generated configuration or keep it as an historical record.
20+
- After importing resources, you can remove the generated `import` block or keep it as an historical record.
2021

2122
### Resource identity
2223

@@ -62,7 +63,7 @@ Add the following arguments to your `list` block:
6263

6364
- `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.
6465

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

6768
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.
6869

content/terraform/v1.14.x (alpha)/docs/language/import/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ When you need to identify and import large sets of infrastructure resources, you
2121

2222
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.
2323

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.

content/terraform/v1.14.x (alpha)/docs/language/meta-arguments.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Integer index. You cannot use both a `count` and ` for_each` argument in the sam
7171

7272
- [`count` argument in `data` blocks](/terraform/language/block/data#count)
7373
- [`count` argument in `ephemeral` blocks](/terraform/language/block/ephemeral#count)
74+
- [`count` argument in `list` blocks](/terraform/language/block/tfquery/list#count)
7475
- [`count` argument in `module` blocks](/terraform/language/block/module#count)
7576
- [`count` argument in `resource` block ](/terraform/language/block/resource#count)
7677

@@ -109,6 +110,7 @@ You cannot use both a `count` and ` for_each` argument in the same block.
109110

110111
- [`for_each` argument in `data` blocks](/terraform/language/block/data#for_each)
111112
- [`for_each` argument in `ephemeral` blocks](/terraform/language/block/ephemeral#for_each)
113+
- [`for_each` argument in `list` blocks](/terraform/language/block/tfquery/list#for_each)
112114
- [`for_each` argument in `module` blocks](/terraform/language/block/module#for_each)
113115
- [`for_each` argument in. `resource` blocks](/terraform/language/block/resource#for_each)
114116

@@ -139,6 +141,7 @@ The `provider` argument is distinct from the `provider` block, which contains pr
139141
- [`provider` argument in `data` blocks](/terraform/language/block/data#provider)
140142
- [`provider` argument in `ephemeral` blocks](/terraform/language/block/ephemeral#provider)
141143
- [`provider` argument in `import` block ](/terraform/language/block/import#provider)
144+
- [`provider` argument in `list` blocks](/terraform/language/block/tfquery/list#provider)
142145
- [`provider` argument in `resource` blocks](/terraform/language/block/resource#provider)
143146

144147
## `providers`

0 commit comments

Comments
 (0)