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.
https://github.com/aztfmod/caf-terraform-landingzones
MIT License
762 stars 666 forks source link

CAF Foundation landing zone - deployment error #56

Closed manavibanerjee closed 4 years ago

manavibanerjee commented 4 years ago

Describe the bug While deploying caf-terraform-landingzones , I get an error that the resources already exit. Error: A resource with the ID "/subscriptions/18ab9f36-e50d-482f-919a-bbfb490d4f4c/providers/Microsoft.Authorization/policyAssignments/vm_auto_monitor" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_policy_assignment" for more information.

on blueprint_foundations_governance/policies/builtin/enable_az_monitor.tf line 4, in resource "azurerm_policy_assignment" "vm_auto_monitor": 4: resource "azurerm_policy_assignment" "vm_auto_monitor" {

Error: A resource with the ID "/subscriptions/18ab9f36-e50d-482f-919a-bbfb490d4f4c/providers/Microsoft.Authorization/policyAssignments/vm_no_managed_disks" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_policy_assignment" for more information.

on blueprint_foundations_governance/policies/builtin/managed_disks.tf line 4, in resource "azurerm_policy_assignment" "pol_managed_disks_assignment": 4: resource "azurerm_policy_assignment" "pol_managed_disks_assignment" {

Error: A resource with the ID "/subscriptions/18ab9f36-e50d-482f-919a-bbfb490d4f4c/providers/microsoft.insights/logprofiles/default" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_monitor_log_profile" for more information.

on /home/vscode/.terraform.cache/modules/blueprint_foundations_accounting.activity_logs/terraform-azurerm-caf-activity-logs-2.0/module.tf line 47, in resource "azurerm_monitor_log_profile" "subscription": 47: resource "azurerm_monitor_log_profile" "subscription" {

Error on or near line 483: Error running terraform apply; exiting with status 2001

I have checked my subscription and nothing was deployed in the southeastasia region and I had only resources deployed by preparation steps which are from: rover /tf/caf/landingzones/launchpad apply -launchpad Subscription resources Status prior to CAF foundation landing zone deployment image

Why does the error report that vm_auto_monitor, vm_no_managed_disks and logprofiles already exists? I have destroyed the whole deployment and started fresh as well but it says the same.

please help.

thanks, Manavi

arnaudlh commented 4 years ago

there as been a previous run of the caf_foundations landing zone where the logprofile (subscription/audit policy) and policy assignment were not successfully destroyed, you need to manually remove the objects.