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
-[`identity`](#identity)   map | mutually exclusive with `id`
19
19
-[`for_each`](#for_each)   map or set of strings
20
20
-[`provider`](#provider)   reference
21
21
@@ -95,20 +95,18 @@ You must specify a string or an expression that evaluates to a string. The ID mu
95
95
96
96
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.
97
97
98
-
<!--// HIDING INFO ABOUT IDENTITY FOR NOW //
99
98
You cannot use the `id` argument and [`identity` argument](#identity) in the same `import` block.
100
-
-->
101
99
102
100
#### Summary
103
101
104
102
- Data type: String
105
103
- Default: None
106
104
- Example: [Import a single resource](#import-a-single-resource)
107
105
108
-
<!-- leave out for now - providers are not using this yet
106
+
109
107
### `identity`
110
108
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.
112
110
113
111
```hcl
114
112
import {
@@ -118,9 +116,7 @@ import {
118
116
}
119
117
```
120
118
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.
124
120
125
121
You cannot use the `identity` argument and [`id` argument](#id) in the same `import` block.
126
122
@@ -130,7 +126,6 @@ You cannot use the `identity` argument and [`id` argument](#id) in the same `imp
130
126
- Default: None
131
127
- Example: [Import a single resource](#import-a-single-resource)
132
128
133
-
-->
134
129
135
130
### `for_each`
136
131
@@ -204,8 +199,13 @@ The following examples show how to write configuration for common use cases.
204
199
205
200
### Import a single resource
206
201
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
+
<Tabheading="Import using ID">
208
207
208
+
In the following example, Terraform imports `example-bucket` into a resource at `aws_s3_bucket.this`:
209
209
210
210
```hcl
211
211
import {
@@ -214,13 +214,34 @@ import {
214
214
}
215
215
216
216
resource "aws_s3_bucket" "this" {
217
-
}
218
217
# …
219
218
}
220
219
```
221
220
222
221
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.
223
222
223
+
</Tab>
224
+
225
+
<Tabheading="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
+
224
245
### Import multiple resources
225
246
226
247
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"]`.
-[`identity`](#identity)   map | mutually exclusive with `id`
19
19
-[`for_each`](#for_each)   map or set of strings
20
20
-[`provider`](#provider)   reference
21
21
@@ -95,20 +95,18 @@ You must specify a string or an expression that evaluates to a string. The ID mu
95
95
96
96
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.
97
97
98
-
<!--// HIDING INFO ABOUT IDENTITY FOR NOW //
99
98
You cannot use the `id` argument and [`identity` argument](#identity) in the same `import` block.
100
-
-->
101
99
102
100
#### Summary
103
101
104
102
- Data type: String
105
103
- Default: None
106
104
- Example: [Import a single resource](#import-a-single-resource)
107
105
108
-
<!-- leave out for now - providers are not using this yet
106
+
109
107
### `identity`
110
108
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.
112
110
113
111
```hcl
114
112
import {
@@ -118,9 +116,7 @@ import {
118
116
}
119
117
```
120
118
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.
124
120
125
121
You cannot use the `identity` argument and [`id` argument](#id) in the same `import` block.
126
122
@@ -130,7 +126,6 @@ You cannot use the `identity` argument and [`id` argument](#id) in the same `imp
130
126
- Default: None
131
127
- Example: [Import a single resource](#import-a-single-resource)
132
128
133
-
-->
134
129
135
130
### `for_each`
136
131
@@ -204,8 +199,13 @@ The following examples show how to write configuration for common use cases.
204
199
205
200
### Import a single resource
206
201
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.
208
203
204
+
<Tabs>
205
+
206
+
<Tabheading="Import using ID">
207
+
208
+
In the following example, Terraform imports `example-bucket` into a resource at `aws_s3_bucket.this`:
209
209
210
210
```hcl
211
211
import {
@@ -214,13 +214,34 @@ import {
214
214
}
215
215
216
216
resource "aws_s3_bucket" "this" {
217
-
}
218
217
# …
219
218
}
220
219
```
221
220
222
221
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.
223
222
223
+
</Tab>
224
+
225
+
<Tabheading="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
+
224
245
### Import multiple resources
225
246
226
247
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"]`.
0 commit comments