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

r/resource_group: feature flag for prevent_deletion_if_contains_resources #12657

Merged
merged 2 commits into from
Aug 11, 2021

Conversation

magodo
Copy link
Collaborator

@magodo magodo commented Jul 20, 2021

This PR introduces a new feature block resource_group with a toggle delete_nested_items_during_deletion (same name as the template_deployment), which by default is false that only allows users to delete a resource group when it is empty.

NOTE This PR makes the toggle to be false by default, which is a breaking change comparing to the current provider behavior. So we'd either merge it for v3.0, or make it true by default.
(Using the ThreePointOh internal toggle might cause miss changes for (e.g.) document when we switching to v3.0 in this case?)

Fixes #1608

Test Result

Run a basic test for VM to ensure when this feature is disabled, the listing by resource group API returns empty list when all the resources inside the resource group are deleted prior to Terraform trying to delete this resource group.

💤 TF_ACC=1 go test -timeout=3h -v ./azurerm/internal/services/compute -run='TestAccLinuxVirtualMachine_authPassword'
=== RUN   TestAccLinuxVirtualMachine_authPassword
=== PAUSE TestAccLinuxVirtualMachine_authPassword
=== RUN   TestAccLinuxVirtualMachine_authPasswordAndSSH
=== PAUSE TestAccLinuxVirtualMachine_authPasswordAndSSH
=== CONT  TestAccLinuxVirtualMachine_authPassword
=== CONT  TestAccLinuxVirtualMachine_authPasswordAndSSH
--- PASS: TestAccLinuxVirtualMachine_authPasswordAndSSH (252.47s)
--- PASS: TestAccLinuxVirtualMachine_authPassword (279.01s)
PASS
ok      github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/compute     279.052s

@magodo magodo added this to the v3.0.0 milestone Jul 20, 2021
@tombuildsstuff tombuildsstuff self-requested a review July 20, 2021 09:46
@tombuildsstuff tombuildsstuff modified the milestones: v3.0.0, v2.72.0 Aug 5, 2021
@tombuildsstuff tombuildsstuff self-assigned this Aug 10, 2021
@tombuildsstuff
Copy link
Contributor

Rebased on top of main

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @magodo

Thanks for this PR - apologies for the delayed review here, I've wanted to spend some time digging into this to ensure the behaviour's what we expect.

I've taken a look through and left some comments inline - since I've rebased this PR anyway I'm going to push a commit to fix those and ask @jackofallops to take another look through, but I think that should enable us to ship this.

Thanks!

internal/features/defaults.go Outdated Show resolved Hide resolved
internal/features/user_flags.go Outdated Show resolved Hide resolved
internal/provider/features.go Outdated Show resolved Hide resolved
internal/provider/features.go Outdated Show resolved Hide resolved
internal/provider/features_test.go Outdated Show resolved Hide resolved
internal/provider/features_test.go Outdated Show resolved Hide resolved
internal/provider/features_test.go Outdated Show resolved Hide resolved
website/docs/index.html.markdown Outdated Show resolved Hide resolved
internal/provider/features_test.go Outdated Show resolved Hide resolved
internal/services/resource/resource_group_resource.go Outdated Show resolved Hide resolved
@github-actions github-actions bot added size/L and removed size/M labels Aug 10, 2021
@tombuildsstuff tombuildsstuff changed the title Feature: resource_group.delete_nested_items_during_deletion r/resource_group: feature flag for prevent_deletion_if_contains_resources Aug 10, 2021
Copy link
Member

@jackofallops jackofallops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@tombuildsstuff tombuildsstuff merged commit ff39d05 into hashicorp:main Aug 11, 2021
tombuildsstuff added a commit that referenced this pull request Aug 11, 2021
@github-actions
Copy link

This functionality has been released in v2.72.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

r/resource_group: feature flag for only deleting when empty / no nested resources
3 participants