Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_container_app_custom_domain - fix when azurerm_container_app has secret specified (#25196) #25251

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading