Azure / caf-terraform-landingzones

This solution, offered by the Open-Source community, will no longer receive contributions from Microsoft. Customers are encouraged to transition to Microsoft Azure Verified Modules for continued support and updates from Microsoft. Please note, this repository is scheduled for decommissioning and will be removed on July 1, 2025.

Home Page:https://github.com/aztfmod/caf-terraform-landingzones

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Single subscription deployment lab failing Destroy

CarlosAugustoDeSouzaJunior opened this issue · comments

Describe the bug

Cannot destroy deployment.

To Reproduce

Deploy until level1/alz/mg/ , and try to destroy after.

rover
--impersonate-sp-from-keyvault-url https://ida-kv-es-qfg.vault.azure.net/
-lz /tf/caf/landingzones/caf_solution/add-ons/caf_eslz
-var-folder /tf/caf/configuration/level1/alz/mg
-tfstate_subscription_id e91f64d9-79ca-4bc7-a8de-b205ec4f0854
-tfstate alz_mg.tfstate
-env idahys
-level level1
-p ${TF_DATA_DIR}/alz_mg.tfstate.tfplan
-a apply

The apply is successful, bur cannot destroy
àrover
--impersonate-sp-from-keyvault-url https://ida-kv-es-qfg.vault.azure.net/
-lz /tf/caf/landingzones/caf_solution/add-ons/caf_eslz
-var-folder /tf/caf/configuration/level1/alz/mg
-tfstate_subscription_id e91f64d9-79ca-4bc7-a8de-b205ec4f0854
-tfstate alz_mg.tfstate
-env idahys
-level level1
-p ${TF_DATA_DIR}/alz_mg.tfstate.tfplan
-a destroy

Error:

Terraform has been successfully initialized!
Line 468 - Terraform init return code 0
Terraform version 0.15 or greater

│ Error: Saved plan is stale

│ The given plan file can no longer be applied because the state was changed by another operation after the plan was
│ created.

Error on or near line 489: Error running terraform destroy; exiting with status 1

The only thing I saw, the subscription was moved to inside level, even If I move the subscription back, it still not working. I have to remove everything by other scripts....

Expected behavior

destroy level1/alv/mg , configuration.

Screenshots
If applicable, add screenshots to help explain your problem.

Configuration (please complete the following information):

  • OS and version: [e.g. Windows 10 1909]
  • Version of the rover[e.g. 22]
  • Version of the landing zone[e.g. 11]

Additional context
Add any other context about the problem here.

I had the same problem (for level 2). I was using the dev container image aztfmod/rover:1.2.5-2208.0208. After upgrading to aztfmod/rover:1.3.4-2211.2307 the destroy command worked for me.
I also didn't need to pass the tfplan file with-p - just -a destroy. Rover will automatically create a destroy plan using the Terraform command plan -destroy and applies it afterwards.