Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
May 21, 2024

Conversation

liamcervante
Copy link
Member

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
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
6 checks passed
@liamcervante liamcervante deleted the liamcervante/35178 branch May 21, 2024 14:28
Copy link

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

Copy link

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