Skip to content

Commit

Permalink
Initial Check-in... (#22683)
Browse files Browse the repository at this point in the history
  • Loading branch information
WodansSon authored Jul 26, 2023
1 parent a7dc972 commit f92e2c6
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions internal/services/cdn/cdn_endpoint_custom_domain_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"time"

"github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2020-09-01/cdn" // nolint: staticcheck
"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonids"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down Expand Up @@ -481,14 +482,20 @@ func expandArmCdnEndpointCustomDomainUserManagedHttpsSettings(ctx context.Contex
return nil, err
}

// Fix for issue #20772
var SecretVersion *string
if keyVaultSecretId.Version != "" {
SecretVersion = pointer.To(keyVaultSecretId.Version)
}

output := &cdn.UserManagedHTTPSParameters{
CertificateSourceParameters: &cdn.KeyVaultCertificateSourceParameters{
OdataType: utils.String("#Microsoft.Azure.Cdn.Models.KeyVaultCertificateSourceParameters"),
SubscriptionID: &keyVaultId.SubscriptionId,
ResourceGroupName: &keyVaultId.ResourceGroupName,
VaultName: &keyVaultId.VaultName,
SecretName: &keyVaultSecretId.Name,
SecretVersion: &keyVaultSecretId.Version,
SubscriptionID: pointer.To(keyVaultId.SubscriptionId),
ResourceGroupName: pointer.To(keyVaultId.ResourceGroupName),
VaultName: pointer.To(keyVaultId.VaultName),
SecretName: pointer.To(keyVaultSecretId.Name),
SecretVersion: SecretVersion,
UpdateRule: utils.String("NoAction"),
DeleteRule: utils.String("NoAction"),
},
Expand Down Expand Up @@ -556,9 +563,11 @@ func flattenArmCdnEndpointCustomDomainUserManagedHttpsSettings(ctx context.Conte
if err != nil {
return nil, err
}

if secret.ID == nil {
return nil, fmt.Errorf("unexpected null Key Vault Secret retrieved for Key Vault %s / Secret Name %s / Secret Version %s", keyVaultId, secretName, secretVersion)
}

secretId, err := keyvaultParse.ParseOptionallyVersionedNestedItemID(*secret.ID)
if err != nil {
return nil, err
Expand Down Expand Up @@ -589,7 +598,9 @@ func flattenArmCdnEndpointCustomDomainUserManagedHttpsSettings(ctx context.Conte
certIdLiteral = certId.VersionlessID()
}
}

m["key_vault_certificate_id"] = certIdLiteral

return []interface{}{m}, nil
}

Expand Down

0 comments on commit f92e2c6

Please sign in to comment.