From a155e4be3f3c3eaf1777b28bd1f3ff4724629c65 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Thu, 19 Oct 2023 15:21:43 +0800 Subject: [PATCH] set only corresponding provider in provider config file --- internal/meta/base_meta.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/meta/base_meta.go b/internal/meta/base_meta.go index 7950569..ff0e0c5 100644 --- a/internal/meta/base_meta.go +++ b/internal/meta/base_meta.go @@ -580,15 +580,17 @@ func (meta *baseMeta) buildTerraformConfig(backendType string) string { func (meta *baseMeta) buildProviderConfig() string { f := hclwrite.NewEmptyFile() - body := f.Body().AppendNewBlock("provider", []string{"azurerm"}).Body() + + var body *hclwrite.Body + if meta.useAzAPI() { + body = f.Body().AppendNewBlock("provider", []string{"azapi"}).Body() + } else { + body = f.Body().AppendNewBlock("provider", []string{"azurerm"}).Body() + } body.AppendNewBlock("features", nil) for k, v := range meta.providerConfig { body.SetAttributeValue(k, v) } - - if meta.useAzAPI() { - f.Body().AppendNewBlock("provider", []string{"azapi"}).Body() - } return string(f.Bytes()) }