Skip to content

Commit 98492c3

Browse files
committed
add details about identity arg in import ref
1 parent 90c0c92 commit 98492c3

File tree

2 files changed

+67
-25
lines changed

2 files changed

+67
-25
lines changed

content/terraform/v1.12.x/docs/language/block/import.mdx

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ An `import` block supports the following configuration:
1414

1515
- [`import`](#import) &nbsp block
1616
- [`to`](#to) &nbsp address | required
17-
- [`id`](#id) &nbsp string
18-
<!-- - [`identity`](#identity) &nbsp map | mutually exclusive with `id` -->
17+
- [`id`](#id) &nbsp string
18+
- [`identity`](#identity) &nbsp map | mutually exclusive with `id`
1919
- [`for_each`](#for_each) &nbsp map or set of strings
2020
- [`provider`](#provider) &nbsp reference
2121

@@ -95,20 +95,18 @@ You must specify a string or an expression that evaluates to a string. The ID mu
9595

9696
The value of the `id` argument depends on the type of resource you are importing. You can only import resources that are supported by the provider. For information on how to import a resource, refer to the provider documentation.
9797

98-
<!--// HIDING INFO ABOUT IDENTITY FOR NOW //
9998
You cannot use the `id` argument and [`identity` argument](#identity) in the same `import` block.
100-
-->
10199

102100
#### Summary
103101

104102
- Data type: String
105103
- Default: None
106104
- Example: [Import a single resource](#import-a-single-resource)
107105

108-
<!-- leave out for now - providers are not using this yet
106+
109107
### `identity`
110108

111-
The `identity` argument specifies a resource identity object that uniquely identifies a resource.
109+
The `identity` argument specifies a set of attributes that uniquely identifies a resource.
112110

113111
```hcl
114112
import {
@@ -118,9 +116,7 @@ import {
118116
}
119117
```
120118

121-
The `identity` argument is an object of key-value pairs that uniquely identify a resource. The keys and values are specific to the resource type and provider.
122-
123-
The key-value pair for the `identity` object depends on the type of resource you are importing. You can only import resources that are supported by the provider. Refer to the provider documentation for information about how to retrieve the `identity`.
119+
The specific attributes are specific to the resource type and provider. You can only import resources that are supported by the provider. Refer to your provider documentation for details.
124120

125121
You cannot use the `identity` argument and [`id` argument](#id) in the same `import` block.
126122

@@ -130,7 +126,6 @@ You cannot use the `identity` argument and [`id` argument](#id) in the same `imp
130126
- Default: None
131127
- Example: [Import a single resource](#import-a-single-resource)
132128

133-
-->
134129

135130
### `for_each`
136131

@@ -204,8 +199,13 @@ The following examples show how to write configuration for common use cases.
204199

205200
### Import a single resource
206201

207-
In the following example, Terraform imports `example-bucket` into a resource at `aws_s3_bucket.this`:
202+
You can import an individual resource by specifying its ID in `id` argument or by specifying the set of identifying attributes in the `identity` argument.
203+
204+
<Tabs>
205+
206+
<Tab heading="Import using ID">
208207

208+
In the following example, Terraform imports `example-bucket` into a resource at `aws_s3_bucket.this`:
209209

210210
```hcl
211211
import {
@@ -214,13 +214,34 @@ import {
214214
}
215215
216216
resource "aws_s3_bucket" "this" {
217-
}
218217
# …
219218
}
220219
```
221220

222221
Refer to the [AWS provider documentation](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance#import) in the Terraform registry for more information about importing AWS instances.
223222

223+
</Tab>
224+
225+
<Tab heading="Import using identity attributes">
226+
227+
In the following example, Terraform imports an S3 bucket using its `account_id`, `bucket`, and `region` attributes:
228+
229+
```hcl
230+
import {
231+
to = aws_s3_bucket.bucket
232+
identity = {
233+
account_id = "622801496880"
234+
bucket = "hjarui4t89efuh"
235+
region = "us-east-1"
236+
}
237+
}
238+
```
239+
240+
241+
</Tab>
242+
243+
</Tabs>
244+
224245
### Import multiple resources
225246

226247
In the following example, the `for_each` argument loops through the key-value pairs defined in the `buckets` map. For each pair, Terraform imports the S3 bucket into the `aws_s3_bucket.this` resource. The `[each.key]` index maps to the keys in `locals` block, such as `aws_s3_bucket.this["staging"]`.

content/terraform/v1.13.x/docs/language/block/import.mdx

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ An `import` block supports the following configuration:
1414

1515
- [`import`](#import) &nbsp block
1616
- [`to`](#to) &nbsp address | required
17-
- [`id`](#id) &nbsp string
18-
<!-- - [`identity`](#identity) &nbsp map | mutually exclusive with `id` -->
17+
- [`id`](#id) &nbsp string
18+
- [`identity`](#identity) &nbsp map | mutually exclusive with `id`
1919
- [`for_each`](#for_each) &nbsp map or set of strings
2020
- [`provider`](#provider) &nbsp reference
2121

@@ -95,20 +95,18 @@ You must specify a string or an expression that evaluates to a string. The ID mu
9595

9696
The value of the `id` argument depends on the type of resource you are importing. You can only import resources that are supported by the provider. For information on how to import a resource, refer to the provider documentation.
9797

98-
<!--// HIDING INFO ABOUT IDENTITY FOR NOW //
9998
You cannot use the `id` argument and [`identity` argument](#identity) in the same `import` block.
100-
-->
10199

102100
#### Summary
103101

104102
- Data type: String
105103
- Default: None
106104
- Example: [Import a single resource](#import-a-single-resource)
107105

108-
<!-- leave out for now - providers are not using this yet
106+
109107
### `identity`
110108

111-
The `identity` argument specifies a resource identity object that uniquely identifies a resource.
109+
The `identity` argument specifies a set of attributes that uniquely identifies a resource.
112110

113111
```hcl
114112
import {
@@ -118,9 +116,7 @@ import {
118116
}
119117
```
120118

121-
The `identity` argument is an object of key-value pairs that uniquely identify a resource. The keys and values are specific to the resource type and provider.
122-
123-
The key-value pair for the `identity` object depends on the type of resource you are importing. You can only import resources that are supported by the provider. Refer to the provider documentation for information about how to retrieve the `identity`.
119+
The specific attributes are specific to the resource type and provider. You can only import resources that are supported by the provider. Refer to your provider documentation for details.
124120

125121
You cannot use the `identity` argument and [`id` argument](#id) in the same `import` block.
126122

@@ -130,7 +126,6 @@ You cannot use the `identity` argument and [`id` argument](#id) in the same `imp
130126
- Default: None
131127
- Example: [Import a single resource](#import-a-single-resource)
132128

133-
-->
134129

135130
### `for_each`
136131

@@ -204,8 +199,13 @@ The following examples show how to write configuration for common use cases.
204199

205200
### Import a single resource
206201

207-
In the following example, Terraform imports `example-bucket` into a resource at `aws_s3_bucket.this`:
202+
You can import an individual resource by specifying its ID in `id` argument or by specifying the set of identifying attributes in the `identity` argument.
208203

204+
<Tabs>
205+
206+
<Tab heading="Import using ID">
207+
208+
In the following example, Terraform imports `example-bucket` into a resource at `aws_s3_bucket.this`:
209209

210210
```hcl
211211
import {
@@ -214,13 +214,34 @@ import {
214214
}
215215
216216
resource "aws_s3_bucket" "this" {
217-
}
218217
# …
219218
}
220219
```
221220

222221
Refer to the [AWS provider documentation](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance#import) in the Terraform registry for more information about importing AWS instances.
223222

223+
</Tab>
224+
225+
<Tab heading="Import using identity attributes">
226+
227+
In the following example, Terraform imports an S3 bucket using its `account_id`, `bucket`, and `region` attributes:
228+
229+
```hcl
230+
import {
231+
to = aws_s3_bucket.bucket
232+
identity = {
233+
account_id = "622801496880"
234+
bucket = "hjarui4t89efuh"
235+
region = "us-east-1"
236+
}
237+
}
238+
```
239+
240+
241+
</Tab>
242+
243+
</Tabs>
244+
224245
### Import multiple resources
225246

226247
In the following example, the `for_each` argument loops through the key-value pairs defined in the `buckets` map. For each pair, Terraform imports the S3 bucket into the `aws_s3_bucket.this` resource. The `[each.key]` index maps to the keys in `locals` block, such as `aws_s3_bucket.this["staging"]`.
@@ -302,4 +323,4 @@ import {
302323
303324
resource "aws_instance" "web" {
304325
# ...
305-
}
326+
}

0 commit comments

Comments
 (0)