Skip to content

[Suggestion] Removing a provider when resources exist is impossible. #5

@JulesClaussen

Description

@JulesClaussen

Hello @antonbabenko , thanks for the skill! It's quite useful :)

I have tested it a bit, and as a suggestion, we could add something mentioning that it's not really possible to remove all the resources of a provider, and the provider itself in a single PR.
This is what is suggested by my current Cursor for example:

## Provider Removal Pattern

**Critical**: When removing a provider, you cannot delete it while resources managed by that provider still exist in Terraform state. This applies to ALL providers.

### Two-Phase Removal Process

**Phase 1: Destroy Resources (Keep Provider)**
1. Remove resource definitions from code (delete resource blocks)
2. Keep provider in `versions.tf` and variables in `vars.tf`
3. Run `terraform plan` - should show resources being destroyed
4. Run `terraform apply` to destroy resources
5. Verify resources are removed from state

**Phase 2: Remove Provider (After Resources Destroyed)**
1. Remove provider from `versions.tf`
2. Remove provider variables from `vars.tf`
3. Delete provider configuration files
4. Run `terraform init -upgrade` to update lock file
5. Verify `terraform plan` shows no errors

**Why this matters:**
- Terraform needs the provider available to destroy resources it manages
- Removing provider before destroying resources causes errors
- This pattern applies universally to all Terraform providers

Thank you!
Jules

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions