Skip to content

import: only filter id attribute at root level when generating config#35220

Merged
liamcervante merged 1 commit intomainfrom
liamcervante/35178
May 21, 2024
Merged

import: only filter id attribute at root level when generating config#35220
liamcervante merged 1 commit intomainfrom
liamcervante/35178

Conversation

@liamcervante
Copy link
Copy Markdown
Contributor

The legacy SDK introduces an id attribute at the root level of resources. This caused invalid config to be generated for the legacy SDK. To avoid this we introduced a filter that removed this attribute from the generated config. This workaround is discussed here: https://github.com/hashicorp/terraform/blob/main/internal/terraform/node_resource_plan_instance.go#L751-L761.

The linked issue highlights we were also removing computed and optional id attributes from within nested attributes and blocks. These id attributes are not introduced by the SDK, so I've changed the filter functionality to accept a path instead of an attribute name and it now only removes attributes at the root level instead of across the whole schema.

Fixes #35178

Target Release

1.8.4

Draft CHANGELOG entry

BUG FIXES

  • import blocks: Fix bug where resources with nested, computed, and optional id attributes would fail to generate.

@liamcervante liamcervante requested a review from a team May 21, 2024 09:04
@liamcervante liamcervante added the 1.8-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged label May 21, 2024
Copy link
Copy Markdown
Member

@kmoe kmoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@liamcervante liamcervante merged commit af4a734 into main May 21, 2024
@liamcervante liamcervante deleted the liamcervante/35178 branch May 21, 2024 14:28
@github-actions
Copy link
Copy Markdown
Contributor

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

@github-actions
Copy link
Copy Markdown
Contributor

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

1.8-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

terraform plan -generate-config-out fails for schemas with nested and computed "id" attributes

2 participants