From f55ac2833cd3c88b673ee424db2dae769883b5e8 Mon Sep 17 00:00:00 2001 From: Heng Lu Date: Thu, 10 Oct 2024 13:29:38 +0800 Subject: [PATCH] add AZTF_MIGRATE_SKIP_COVERAGE_CHECK to skip coverage check --- readme.md | 8 ++++++++ types/azapi_resource.go | 4 ++++ types/azapi_update_resource.go | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/readme.md b/readme.md index 9894b190..cecf4409 100644 --- a/readme.md +++ b/readme.md @@ -138,6 +138,14 @@ yay -S aztfmigrate 2. Usage of `dynamic` can't be migrated. 3. Update resource used to manage CMK can't be migrated. +## Advanced usage + +1. Adding the below environment variable will skip the coverage check when migrating the azapi resources to azurerm resources. + +``` +AZTF_MIGRATE_SKIP_COVERAGE_CHECK = true +``` + ## Credits We wish to thank HashiCorp for the use of some MPLv2-licensed code from their open source project [terraform-plugin-sdk](https://github.com/hashicorp/terraform-plugin-sdk). diff --git a/types/azapi_resource.go b/types/azapi_resource.go index 26c7d59e..48d2ba2e 100644 --- a/types/azapi_resource.go +++ b/types/azapi_resource.go @@ -2,6 +2,7 @@ package types import ( "fmt" + "os" "strconv" "strings" @@ -151,6 +152,9 @@ func (r *AzapiResource) TargetProvider() string { } func (r *AzapiResource) CoverageCheck(strictMode bool) error { + if os.Getenv("AZTF_MIGRATE_SKIP_COVERAGE_CHECK") == "true" { + return nil + } resourceId := r.Instances[0].ResourceId idPattern, _ := GetIdPattern(resourceId) if strictMode { diff --git a/types/azapi_update_resource.go b/types/azapi_update_resource.go index 2527cf87..912b6f86 100644 --- a/types/azapi_update_resource.go +++ b/types/azapi_update_resource.go @@ -2,6 +2,7 @@ package types import ( "fmt" + "os" "strings" "github.com/Azure/aztfmigrate/azurerm/coverage" @@ -80,6 +81,9 @@ func (r *AzapiUpdateResource) TargetProvider() string { } func (r *AzapiUpdateResource) CoverageCheck(strictMode bool) error { + if os.Getenv("AZTF_MIGRATE_SKIP_COVERAGE_CHECK") == "true" { + return nil + } idPattern, _ := GetIdPattern(r.Id) if strictMode { azurermApiVersion := coverage.GetApiVersion(idPattern)