-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
azurerm_storage_account
: Support managed HSMs for CMKs (#25088)
* managedhsm: introducing dedicated Resource ID Parsers for the Data Plane Versioned and Versionless Key IDs * `azurerm_storage_account` - support HSMs * `azurerm_storage_account_customer_managed_key` - support HSMs * Extract "IsManagedHSMURI" helper * Update storage_account_resource.go err != nil -> err == nil * Update storage_account_customer_managed_key_resource.go err != nil -> err == nil --------- Co-authored-by: tombuildsstuff <[email protected]> Co-authored-by: kt <[email protected]> Co-authored-by: Matthew Frahry <[email protected]>
- Loading branch information
1 parent
87a7d40
commit 982d373
Showing
5 changed files
with
202 additions
and
65 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
internal/services/managedhsm/helpers/is_managed_hsm_uri.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package helpers | ||
|
||
import ( | ||
"fmt" | ||
"net/url" | ||
"strings" | ||
|
||
"github.com/hashicorp/go-azure-sdk/sdk/environments" | ||
"github.com/hashicorp/terraform-provider-azurerm/utils" | ||
) | ||
|
||
func IsManagedHSMURI(env environments.Environment, uri string) (bool, error, string, string) { | ||
url, err := url.Parse(uri) | ||
if err != nil { | ||
return false, fmt.Errorf("Error parsing %s as URI: %+v", uri, err), "", "" | ||
} | ||
|
||
instanceName, domainSuffix, found := strings.Cut(url.Hostname(), ".") | ||
if !found { | ||
return false, fmt.Errorf("Key vault URI hostname does not have the right number of components: %s", url.Hostname()), "", "" | ||
} | ||
expectedDomainSuffix, found := env.ManagedHSM.DomainSuffix() | ||
if !found { | ||
expectedDomainSuffix = utils.String("managedhsm.azure.net") | ||
} | ||
if domainSuffix == *expectedDomainSuffix { | ||
return true, nil, instanceName, domainSuffix | ||
} else { | ||
return false, nil, "", "" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.