Backport of Add resource identity documentation into v1.12 (#37140)

* backport of commit 53dd743525

* backport of commit d86fc1a255

* backport of commit 463386f8c8

---------

Co-authored-by: Daniel Banck <daniel@dbanck.de>
Co-authored-by: trujillo-adam <47586768+trujillo-adam@users.noreply.github.com>
backport/radditude/remove-cgo-default/personally-calm-cat
github-actions[bot] 1 year ago committed by GitHub
parent 9e43e0326e
commit da85ac8376
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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).

Loading…
Cancel
Save