Skip to content

Commit

Permalink
azurerm_container_app_custom_domain - fix when `azurerm_container_a…
Browse files Browse the repository at this point in the history
…pp` has `secret` specified (#25196) (#25251)

* Fixes issue with secrets not being populated when updating custom domain

* Fixes missing imports
  • Loading branch information
AButler authored Mar 21, 2024
1 parent be1a182 commit c6ad3a7
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ package containerapps
import (
"context"
"fmt"
"net/http"
"strings"
"time"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2023-05-01/containerapps"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2023-05-01/managedenvironments"
"github.com/hashicorp/terraform-provider-azurerm/internal/locks"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/containerapps/helpers"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/containerapps/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/containerapps/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
Expand Down Expand Up @@ -124,6 +127,15 @@ func (a ContainerAppCustomDomainResource) Create() sdk.ResourceFunc {
return fmt.Errorf("specified Container App (%s) has no Ingress configuration for Custom Domains", containerAppId)
}

// Delta-updates need the secrets back from the list API, or we'll end up removing them or erroring out.
secretsResp, err := client.ListSecrets(ctx, *containerAppId)
if err != nil || secretsResp.Model == nil {
if !response.WasStatusCode(secretsResp.HttpResponse, http.StatusNoContent) {
return fmt.Errorf("retrieving secrets for update for %s: %+v", *containerAppId, err)
}
}
config.Secrets = helpers.UnpackContainerSecretsCollection(secretsResp.Model)

ingress := *config.Ingress

customDomains := make([]containerapps.CustomDomain, 0)
Expand Down

0 comments on commit c6ad3a7

Please sign in to comment.