From da85ac837666437ba8e71f4cb930fcd509483580 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 20 May 2025 16:07:18 +0000 Subject: [PATCH] Backport of Add resource identity documentation into v1.12 (#37140) * backport of commit 53dd743525ecd2d87e9ac77bbf445b1aa27dfdff * backport of commit d86fc1a2553522e08a0cbd31ecb7b3c93b8f2200 * backport of commit 463386f8c8b89b3a5ac216af384406f1dbbb6ce3 --------- Co-authored-by: Daniel Banck Co-authored-by: trujillo-adam <47586768+trujillo-adam@users.noreply.github.com> --- website/docs/language/import/index.mdx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/website/docs/language/import/index.mdx b/website/docs/language/import/index.mdx index 8390af81aa..d6d8727483 100644 --- a/website/docs/language/import/index.mdx +++ b/website/docs/language/import/index.mdx @@ -36,7 +36,8 @@ The above `import` block defines an import of the AWS instance with the ID "i-ab The `import` block has the following arguments: - `to` - The instance address this resource will have in your state file. - - `id` - A string with the [import ID](#import-id) of the resource, or an expression that evaluates to a string. + - `id` - A string with the [import ID](#import-id) of the resource, or an expression that evaluates to a string. This argument is mutually exclusive with `identity`. + - `identity` - A resource identity object that uniquely identifies a resource. It is mutually exclusive with `id`. - `provider` (optional) - An optional custom resource provider, see [The Resource provider Meta-Argument](/terraform/language/meta-arguments/resource-provider) for details. If you do not set the `provider` argument, Terraform attempts to import from the default provider. @@ -49,6 +50,8 @@ The import ID must be known at plan time for planning to succeed. If the value o The identifier you use for a resource's import ID is resource-specific. You can find the required ID in the [provider documentation](https://registry.terraform.io/browse/providers) for the resource you wish to import. +Instead of the `id` argument you can also use the `identity` argument, which represents a resource's identity. 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. + ### Import multiple instances with `for_each` Multiple resource instances can be imported via a single `import` block using the `for_each` argument. The `for_each` argument accepts a collection to iterate over, and results in an `each` iterator in the same manner as it does for [`dynamic` blocks](/terraform/language/expressions/dynamic-blocks). The `for_each` argument must be entirely known for the import plan to succeed, and `for_each` cannot be used when [generating configuration](/terraform/language/import/generating-configuration).