Skip to content

Support re-rolling unrolled recursive TF typesย #1468

@iwahbe

Description

@iwahbe

Hello!

  • Vote on this issue by adding a ๐Ÿ‘ reaction
  • If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)

Issue details

The terraform type system is structural, meaning that subtypes are not named. This prevents terraform from describing recursive types. Terraform providers fake recursion by manually unrolling recursive types to a given depth, generating a huge number of types in the process.

Pulumi needs to generate an in-code representation of these types leading to PRs like this:

Screenshot 2023-10-24 at 2 34 46 PM

Pulumi's type system is nominal (mirroring most programming languages), and we do support recursive types. Recursive typing is worse in Pulumi then it is in TF (for bridged providers) because of the translation, but Pulumi providers can actually offer a better experience than TF providers here.

Solution

The bridge should have native support for re-rolling recursive types back into their recursive descriptions.

A MVP implementation enables designating a resource type on ProviderInfo as "unrolled recursive" on specific fields. The bridge would then handle re-rolling that type.

An ideal solution would automatically detect deep nesting, and then re-roll without manually marking as recursive. This would require inferring that a type is recursive, and on what fields it recurses on, then calling into the MVP solution.

Backwards compatibility

The MVP is fully backwards compatible, since it is off by default. Automatic detection is technically breaking, but we can configure it so that it only breaks providers with an unusable number of resources (wafv2 style).

Affected area/feature

Prior Art

Metadata

Metadata

Assignees

No one assigned

    Labels

    impact/performanceSomething is slower than expectedkind/enhancementImprovements or new featuressize/MEstimated effort to complete (up to 5 days).

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions