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

[Feature]: Migrate resources to terraform plugin framework #612

Open
11 of 67 tasks
ocobles opened this issue Mar 5, 2024 · 1 comment
Open
11 of 67 tasks

[Feature]: Migrate resources to terraform plugin framework #612

ocobles opened this issue Mar 5, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@ocobles
Copy link
Contributor

ocobles commented Mar 5, 2024

We are in the process of migrating all Terraform resources previously defined using the SDKv2 to the Terraform Framework. The utilization of the terraform-plugin-mux Go module has been successfully implemented to facilitate the gradual migration of resources. We have also adopted internal/ layout structure so the resources that are migrated to the framework must now be in their own compartment within internal/{services}/{resource}

Migrate to terraform plugin framework
adopt internal/ layout structure #106

Checklist for Unmigrated Resources

Fabric Resources

Metal Resources

Network Edge Resources

Checklist for Unmigrated Datasources

Fabric Datasources

Metal Datasources

Network Edge Datasources

Migration Guide

Code in https://github.com/equinix/terraform-provider-equinix/blob/framework_migr_resources/internal/metal_organization/resource.go should be used as a base to migrate this resource.

Checkout the sdkv2 version https://github.com/equinix/terraform-provider-equinix/blob/main/equinix/resource_metal_organization.go

Checkout official documentation https://developer.hashicorp.com/terraform/plugin/framework/migrating/attributes-blocks/blocks for mapping between SDK Schema Fields and the Framewor. Here's also the link to recommended steps https://developer.hashicorp.com/terraform/plugin/framework/migrating#migration-steps

  1. Code structure:

    • Separate the code into the following files:
      • models.go
      • resource.go
      • resource_schema.go
      • resource_test.go
  2. Schema Review:

    • Review the resource schema and compare it with the SDKv2 code to ensure no validation or planmodifier has been forgotten.
  3. Update Imports:

    • Review and update imports as necessary. Some imports might have been renamed or moved.
  4. Rename Functions and Variables:

    • Rename functions and variables to follow the same standards as in the already migrated resources (e.g., OrganizationResourceModel to ResourceModel or organizationResourceSchema to resourceSchema).
  5. Migrate End-to-End Tests (e2e):

    • Update end-to-end tests (e2e) to use ProtoV5ProviderFactories: acceptance.ProtoV5ProviderFactories instead of Providers: testAccProviders.
    • Add an additional test to verify the migration is correct. You can use the test added in ssh_key as a reference, TestAccMetalSSHKey_upgradeFromVersion.
  6. Verification and Testing:

    • Verify that the new code functions as expected and that all tests pass.
  7. Migrate Equivalent Data Source (if applicable):

    • If there exists an equivalent data source for the resource being migrated, it should also be migrated in the same Pull Request (PR).
    • Follow the same steps as above for migrating the data source, using the following files:
      • datasource.go
      • datasource_test.go
      • datasource_schema.go
    • Ensure that the data source is updated to match the changes made in the resource migration.
@ocobles ocobles added the enhancement New feature or request label Mar 5, 2024
@ctreatma
Copy link
Contributor

ctreatma commented Mar 5, 2024

Noting here that ECX resources are probably not worth migrating, since the ECX API will be shut down this year, after which time the resources can be deleted entirely.. ECX support was removed in v2.0.0 and I have removed those resources & data sources from the issue description.

ctreatma added a commit that referenced this issue Mar 19, 2024
Part of #612

---------

Co-authored-by: codinja1188 <[email protected]>
Co-authored-by: Charles Treatman <[email protected]>
ctreatma added a commit that referenced this issue Mar 19, 2024
Part of #612

---------

Signed-off-by: Ayush Rangwala <[email protected]>
Signed-off-by: Charles Treatman <[email protected]>
Co-authored-by: Charles Treatman <[email protected]>
ctreatma added a commit that referenced this issue Mar 20, 2024
…amework (#604)

Part of #612

---------

Signed-off-by: ocobleseqx <[email protected]>
Signed-off-by: Óscar Cobles <[email protected]>
Co-authored-by: Charles Treatman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants