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_eventhub_namespace_customer_managed_key - validating that the User Assigned Identity used for accessing the Key Vault is assigned to the EventHub Namespace #25809

Merged
merged 10 commits into from
May 31, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ func resourceEventHubNamespaceCustomerManagedKeyCreateUpdate(d *pluginsdk.Resour

isIdentityAssignedToParent := false
for item := range namespace.Identity.IdentityIds {
if item == userAssignedIdentity {
parentEhnUaiId, err := commonids.ParseUserAssignedIdentityIDInsensitively(item)
if err != nil {
return fmt.Errorf("parsing %q as a User Assigned Identity ID: %+v", item, err)
}
if parentEhnUaiId.ID() == userAssignedIdentity {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than comparing these two IDs by checking the results of .ID() match - can we compare the Resource ID values instead:

Suggested change
if parentEhnUaiId.ID() == userAssignedIdentity {
if resourceids.Match(parentEhnUaiId, userAssignedIdentity) {

The Match function is available in hashicorp/go-azure-helpers#234 fwiw

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isIdentityAssignedToParent = true
}
}
Expand Down