Skip to content

Refactor resources to use the lifecycle field enabled instead of count conditionals #236

@edersonbrilhante

Description

@edersonbrilhante

Summary

Refactor resources to use the lifecycle field enabled instead of count conditionals, and introduce moved blocks to perform automatic state migrations. This will simplify resource logic, improve readability, and ensure compatibility with upcoming lifecycle and ephemeral-resource changes.

Background

Several resources currently rely on count = condition ? 1 : 0 as an enable/disable mechanism. With newer OpenTofu lifecycle capabilities, the preferred approach is the enabled lifecycle meta-argument, which cleanly expresses conditional creation without altering resource indexing.

Since switching from count to enabled changes the resource address, we must provide a moved block to migrate existing state seamlessly. This prevents accidental destruction and re-creation of resources during rollout.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions