Skip to content

[MAINT] Migrate all resources and data sources to Context-aware CRUD functions #2996

Open

Description

@deiga

Summary

This issue tracks the migration of all resources and data sources from legacy CRUD functions (Create, Read, Update, Delete) to Context-aware CRUD functions (CreateContext, ReadContext, UpdateContext, DeleteContext).

Why This Migration Is Needed

Per the Terraform Plugin SDK v2 Upgrade Guide:

  1. Deprecation: The legacy CRUD function types (CreateFunc, ReadFunc, UpdateFunc, DeleteFunc) are deprecated in favor of their context-aware counterparts
  2. Reliable Timeouts & Cancellation: Context-aware functions plumb context.Context throughout the SDK, enabling better request lifecycle management
  3. Improved Error Handling: Migration to diag.Diagnostics allows returning multiple errors and warnings while associating them with specific fields

Related Issues

Migration Pattern

Before (Legacy)

func resourceGithubExample() *schema.Resource {
    return &schema.Resource{
        Create: resourceGithubExampleCreate,
        Read:   resourceGithubExampleRead,
        Update: resourceGithubExampleUpdate,
        Delete: resourceGithubExampleDelete,
        // ...
    }
}

func resourceGithubExampleCreate(d *schema.ResourceData, meta interface{}) error {
    // ...
    return nil
}

After (Context-Aware)

func resourceGithubExample() *schema.Resource {
    return &schema.Resource{
        CreateContext: resourceGithubExampleCreate,
        ReadContext:   resourceGithubExampleRead,
        UpdateContext: resourceGithubExampleUpdate,
        DeleteContext: resourceGithubExampleDelete,
        // ...
    }
}

func resourceGithubExampleCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
    // Use ctx in API calls for proper cancellation support
    // ...
    return nil
}

Current Status

  • Total files: 153
  • Already migrated: 20
  • Remaining: 133

Migration Checklist

Resources (85 files)

Actions

  • resource_github_actions_environment_secret.go
  • resource_github_actions_environment_variable.go
  • resource_github_actions_hosted_runner.go
  • resource_github_actions_organization_oidc_subject_claim_customization_template.go
  • resource_github_actions_organization_permissions.go
  • resource_github_actions_organization_secret.go
  • resource_github_actions_organization_secret_repositories.go
  • resource_github_actions_organization_secret_repository.go
  • resource_github_actions_organization_variable.go
  • resource_github_actions_repository_access_level.go
  • resource_github_actions_repository_oidc_subject_claim_customization_template.go
  • resource_github_actions_repository_permissions.go
  • resource_github_actions_runner_group.go
  • resource_github_actions_secret.go
  • resource_github_actions_variable.go

App Installation

  • resource_github_app_installation_repositories.go
  • resource_github_app_installation_repository.go

Branch

  • resource_github_branch.go
  • resource_github_branch_default.go
  • resource_github_branch_protection.go
  • resource_github_branch_protection_v3.go

Codespaces

  • resource_github_codespaces_organization_secret.go
  • resource_github_codespaces_organization_secret_repositories.go
  • resource_github_codespaces_secret.go
  • resource_github_codespaces_user_secret.go

Dependabot

  • resource_github_dependabot_organization_secret.go
  • resource_github_dependabot_organization_secret_repositories.go
  • resource_github_dependabot_secret.go

Enterprise

  • resource_github_enterprise_actions_permissions.go
  • resource_github_enterprise_actions_runner_group.go
  • resource_github_enterprise_actions_workflow_permissions.go
  • resource_github_enterprise_organization.go
  • resource_github_enterprise_security_analysis_settings.go

EMU

  • resource_github_emu_group_mapping.go

Issues

  • resource_github_issue.go
  • resource_github_issue_label.go
  • resource_github_issue_labels.go

Membership

  • resource_github_membership.go ✅

Organization

  • resource_github_organization_custom_properties.go
  • resource_github_organization_custom_role.go
  • resource_github_organization_project.go
  • resource_github_organization_repository_role.go ✅
  • resource_github_organization_role.go ✅
  • resource_github_organization_role_team.go ✅
  • resource_github_organization_role_team_assignment.go
  • resource_github_organization_role_user.go ✅
  • resource_github_organization_ruleset.go ✅
  • resource_github_organization_security_manager.go
  • resource_github_organization_settings.go
  • resource_github_organization_webhook.go
  • resource_organization_block.go

Projects

  • resource_github_project_card.go
  • resource_github_project_column.go

Release

  • resource_github_release.go

Repository

  • resource_github_repository.go ✅
  • resource_github_repository_autolink_reference.go
  • resource_github_repository_collaborator.go
  • resource_github_repository_collaborators.go
  • resource_github_repository_custom_property.go
  • resource_github_repository_dependabot_security_updates.go
  • resource_github_repository_deploy_key.go
  • resource_github_repository_deployment_branch_policy.go
  • resource_github_repository_environment.go
  • resource_github_repository_environment_deployment_policy.go ✅
  • resource_github_repository_file.go
  • resource_github_repository_milestone.go
  • resource_github_repository_project.go
  • resource_github_repository_pull_request.go
  • resource_github_repository_ruleset.go ✅
  • resource_github_repository_topics.go
  • resource_github_repository_webhook.go

Team

  • resource_github_team.go ✅
  • resource_github_team_members.go
  • resource_github_team_membership.go
  • resource_github_team_repository.go
  • resource_github_team_settings.go
  • resource_github_team_sync_group_mapping.go

User

  • resource_github_user_gpg_key.go
  • resource_github_user_invitation_accepter.go
  • resource_github_user_ssh_key.go

Workflow

  • resource_github_workflow_repository_permissions.go

Data Sources (72 files)

Actions

  • data_source_github_actions_environment_public_key.go
  • data_source_github_actions_environment_secrets.go
  • data_source_github_actions_environment_variables.go
  • data_source_github_actions_organization_oidc_subject_claim_customization_template.go
  • data_source_github_actions_organization_public_key.go
  • data_source_github_actions_organization_registration_token.go
  • data_source_github_actions_organization_secrets.go
  • data_source_github_actions_organization_variables.go
  • data_source_github_actions_public_key.go
  • data_source_github_actions_registration_token.go
  • data_source_github_actions_repository_oidc_subject_claim_customization_template.go
  • data_source_github_actions_secrets.go
  • data_source_github_actions_variables.go

App

  • data_source_github_app.go
  • data_source_github_app_token.go

Branch

  • data_source_github_branch.go
  • data_source_github_branch_protection_rules.go

Codespaces

  • data_source_github_codespaces_organization_public_key.go
  • data_source_github_codespaces_organization_secrets.go
  • data_source_github_codespaces_public_key.go
  • data_source_github_codespaces_secrets.go
  • data_source_github_codespaces_user_public_key.go
  • data_source_github_codespaces_user_secrets.go

Collaborators

  • data_source_github_collaborators.go

Dependabot

  • data_source_github_dependabot_organization_public_key.go
  • data_source_github_dependabot_organization_secrets.go
  • data_source_github_dependabot_public_key.go
  • data_source_github_dependabot_secrets.go

Enterprise

  • data_source_github_enterprise.go

External Groups

  • data_source_github_external_groups.go

IP Ranges

  • data_source_github_ip_ranges.go

Issues

  • data_source_github_issue_labels.go

Membership

  • data_source_github_membership.go

Organization

  • data_source_github_organization.go
  • data_source_github_organization_custom_properties.go
  • data_source_github_organization_custom_role.go
  • data_source_github_organization_external_identities.go
  • data_source_github_organization_ip_allow_list.go
  • data_source_github_organization_repository_role.go ✅
  • data_source_github_organization_repository_roles.go ✅
  • data_source_github_organization_role.go ✅
  • data_source_github_organization_role_teams.go ✅
  • data_source_github_organization_role_users.go ✅
  • data_source_github_organization_roles.go ✅
  • data_source_github_organization_security_managers.go
  • data_source_github_organization_team_sync_groups.go
  • data_source_github_organization_teams.go
  • data_source_github_organization_webhooks.go

Ref

  • data_source_github_ref.go

Release

  • data_source_github_release.go

Repository

  • data_source_github_repositories.go
  • data_source_github_repository.go ✅
  • data_source_github_repository_autolink_references.go
  • data_source_github_repository_branches.go
  • data_source_github_repository_custom_properties.go
  • data_source_github_repository_deploy_keys.go
  • data_source_github_repository_deployment_branch_policies.go
  • data_source_github_repository_environment_deployment_policies.go ✅
  • data_source_github_repository_environments.go
  • data_source_github_repository_file.go ✅
  • data_source_github_repository_milestone.go
  • data_source_github_repository_pull_request.go
  • data_source_github_repository_pull_requests.go
  • data_source_github_repository_teams.go
  • data_source_github_repository_webhooks.go

REST API

  • data_source_github_rest_api.go

SSH Keys

  • data_source_github_ssh_keys.go

Team

  • data_source_github_team.go ✅

Tree

  • data_source_github_tree.go

User

  • data_source_github_user.go
  • data_source_github_user_external_identity.go
  • data_source_github_users.go

Suggested Approach

  1. Pair with tflog migration: When migrating a file, also convert logging to tflog ([MAINT] Tracking issue for refactoring logging to use tflog instead of log #3070)
  2. Batch by domain: Group related resources/data sources and migrate them together
  3. Reference existing migrations: Use already-migrated files as reference implementations
  4. Update function signatures: Change CRUD function signatures to include ctx context.Context and return diag.Diagnostics
  5. Pass context to API calls: Update go-github client calls to use the context parameter
  6. Test thoroughly: Ensure acceptance tests pass after each batch migration

References

Activity

  1. github-actions commented on Dec 10, 2025

    @github-actions

    👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

  2. added
    Status: Up for grabs
    Good first issue
    on Dec 10, 2025
  3. stevehipwell commented on Dec 10, 2025

    @stevehipwell
    Collaborator

    We will want to add provider scoped timeouts even if we don't expose this as a setting initially. This timeout will be important for rate limit handling, as if the delay is longer than the timeout there is no point waiting so we might as well exit early.

  4. deiga commented on Dec 10, 2025

    @deiga
    CollaboratorAuthor

    We will want to add provider scoped timeouts even if we don't expose this as a setting initially. This timeout will be important for rate limit handling, as if the delay is longer than the timeout there is no point waiting so we might as well exit early.

    @stevehipwell Excellent point. But I wonder if that should be a separate "Epic"?

  5. stevehipwell commented on Dec 10, 2025

    @stevehipwell
    Collaborator

    I was thinking of setting a const and requiring the timeouts to be set to that const before we check off the resource. Then it'd be much simpler to refactor it later. This is all just off the top of my head and needs a bit more investigation.

  6. 11 remaining items

  7. deiga commented on Feb 3, 2026

    @deiga
    CollaboratorAuthor

    Checklist Update

    The following resources were migrated to context-aware CRUD functions in PR #3036 (merged Jan 16, 2026):

    Resources

    • resource_github_release.go ✅

    Data Sources

    • data_source_github_release.go ✅

    PR Reference: #3036


    Note: The new data_source_github_release_asset.go added in PR #2514 was implemented with context-aware functions from the start, so no tracking needed.

  8. github-actions commented on Nov 1, 2026

    @github-actions

    👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!

  9. added
    Status: Stale
    on Nov 1, 2026
  10. removed
    Status: Stale
    on Nov 1, 2026
  11. added
    Type: Maintenance
    Status: Pinned
    and removed
    Status: Up for grabs
    Good first issue
    on Nov 27, 2026
  12. stevehipwell commented on Nov 27, 2026

    @stevehipwell
    Collaborator

    @deiga it might be better to update this issue to point at the RESOURCES.md file as the status tracker?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: PinnedType: Maintenance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions