Azure / terraform-azurerm-lz-vending

Terraform module to deploy landing zone subscriptions (and much more) in Azure
https://registry.terraform.io/modules/Azure/lz-vending/azurerm
MIT License
162 stars 70 forks source link

feat: delete reaources prior to cancel sub #405

Open lukemurraynz opened 3 weeks ago

lukemurraynz commented 3 weeks ago

Community Note

Versions

Please paste the output of terraform version command from within the initialized directory:

1.7.4

Please enter the module version that you are using:

4.0.2

Description

Steps to Reproduce

Destroy subscription, containing resources, such as API Management.

│ Error: failed to cancel Subscription: subscriptions.SubscriptionsClient#SubscriptionCancel: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="ResourcesExistingOnSubscription" Message="There are existing resources associated with subscription. Delete them before cancelling the subscription"

Screenshots

Additional context

In my context, we are using Subscriptions for a Sandbox environment, so the Subscriptions exist for a limited time; using the Azure Portal, we can force the cancellation and ignore the resources. It would be great to have the same functionality else the Subscription seems to remain Active, with RBAC assignments stripped, even though it was removed from the state file.

matt-FFFFFF commented 3 weeks ago

Hi,

We will consider this feature for a future version. Currently it's working as designed as the feature to delete resources prior to cancellation is not available in the subscriptions api.