-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Terraform 1.12.0 introduced a new identity
attribute for import blocks as an alternative to the traditional id
attribute. This allows resources to be imported using a structured object of key-value pairs instead of a single ID string.
Current Behavior
The terraform-schema library currently only recognizes the id
attribute for import blocks and treats identity
as an unexpected attribute, resulting in validation errors:
Unexpected attribute: An attribute named "identity" is not expected here
Required attribute "id" not specified: An attribute named "id" is required here
Expected Behavior
The schema for import blocks should accept either id
OR identity
attributes (mutually exclusive), matching Terraform 1.12.0+ behavior.
Example
# Should be valid in Terraform 1.12.0+
import {
to = aws_instance.example
identity = {
instance_id = "i-1234567890abcdef0"
region = "us-west-2"
}
}
References
- Terraform 1.12.0 release notes: https://github.com/hashicorp/terraform/releases/tag/v1.12.0
- Terraform documentation on import blocks: https://developer.hashicorp.com/terraform/language/import
- Related VS Code extension issue: The feature of resource identities is not supported for Import blocks vscode-terraform#2025
Impact
This affects all tools that rely on terraform-schema for validation, including:
- terraform-ls (Terraform Language Server)
- VS Code Terraform extension
- Other IDE integrations
Proposed Solution
Update the import block schema to support both id
and identity
attributes as mutually exclusive options, with version constraints to ensure compatibility (identity only available for Terraform >= 1.12.0).