Skip to content

fix(helper/schema): resolve SchemaFunc when generating resource configuration - #1637

Open
IgnatG wants to merge 1 commit into
hashicorp:mainfrom
IgnatG:fix-generate-config-schemafunc
Open

IgnatG wants to merge 1 commit into
hashicorp:mainfrom
IgnatG:fix-generate-config-schemafunc

Conversation

@IgnatG

@IgnatG IgnatG commented Nov 24, 2026

Copy link
Copy Markdown

Related Issue

Fixes hashicorp/terraform-provider-aws#51306

Description

GenerateResourceConfig looks attributes and blocks up with schemaMap(res.Schema) since #1566. A resource defined with SchemaFunc has a nil Schema field, so neither lookup finds anything, no value is nulled out, and the whole state is returned as the generated configuration: computed-only attributes, id, empty strings and conflicting arguments. Terraform then rejects the configuration.

The AWS provider defines most of its resources with SchemaFunc, so since it moved to v2.41.1 (v6.74.0) terraform plan -generate-config-out fails for them (for example aws_iam_role returns arn, unique_id, create_date and both name and name_prefix).

This resolves the schema once with res.SchemaMap(), which returns SchemaFunc() when it is set and Schema otherwise, as the rest of the package does. A new schema-func-resource case in TestGenerateResourceConfig defines its resource with SchemaFunc; it fails without the change and passes with it, and the helper/schema tests pass.

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

No.

@hashicorp-cla-app

hashicorp-cla-app Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@IgnatG
IgnatG force-pushed the fix-generate-config-schemafunc branch from b7b582e to 32ae2d9 Compare November 24, 2026 16:03
@IgnatG IgnatG changed the title helper/schema: resolve SchemaFunc when generating resource configuration fix(helper/schema): resolve SchemaFunc when generating resource configuration Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: -generate-config-out writes the full state (computed attributes, id) as configuration since v6.74.0 (terraform-plugin-sdk 2.41.1)

1 participant