-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
New Resource: azurerm_servicebus_namespace_customer_managed_key
#28888
base: main
Are you sure you want to change the base?
Conversation
identityId, err := commonids.ParseUserAssignedIdentityID(cmk.IdentityID) | ||
if err != nil { | ||
return err | ||
} | ||
(*payload.Properties.Encryption.KeyVaultProperties)[0].Identity = &namespaces.UserAssignedIdentityProperties{ | ||
UserAssignedIdentity: pointer.To(identityId.ID()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validation function on the property will ensure that the user input is a user assigned identity ID with correct casing in the static segments, so there isn't strictly a need to parse that here if we're just passing the string value of it to the API
identityId, err := commonids.ParseUserAssignedIdentityID(cmk.IdentityID) | |
if err != nil { | |
return err | |
} | |
(*payload.Properties.Encryption.KeyVaultProperties)[0].Identity = &namespaces.UserAssignedIdentityProperties{ | |
UserAssignedIdentity: pointer.To(identityId.ID()), | |
(*payload.Properties.Encryption.KeyVaultProperties)[0].Identity = &namespaces.UserAssignedIdentityProperties{ | |
UserAssignedIdentity: pointer.To(cmk.IdentityID), |
var state ServiceBusNamespaceCustomerManagedKeyModel | ||
state.NamespaceID = id.ID() | ||
|
||
if props := resp.Model.Properties; props != nil && props.Encryption != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also nil check model here:
if props := resp.Model.Properties; props != nil && props.Encryption != nil { | |
if model := resp.Model; model != nil { | |
if props := model.Properties; props != nil && props.Encryption != nil { | |
... | |
} |
identityId, err := commonids.ParseUserAssignedIdentityID(cmk.IdentityID) | ||
if err != nil { | ||
return err | ||
} | ||
(*payload.Properties.Encryption.KeyVaultProperties)[0].Identity = &namespaces.UserAssignedIdentityProperties{ | ||
UserAssignedIdentity: pointer.To(identityId.ID()), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
identityId, err := commonids.ParseUserAssignedIdentityID(cmk.IdentityID) | |
if err != nil { | |
return err | |
} | |
(*payload.Properties.Encryption.KeyVaultProperties)[0].Identity = &namespaces.UserAssignedIdentityProperties{ | |
UserAssignedIdentity: pointer.To(identityId.ID()), | |
} | |
(*payload.Properties.Encryption.KeyVaultProperties)[0].Identity = &namespaces.UserAssignedIdentityProperties{ | |
UserAssignedIdentity: pointer.To(cmk.IdentityID), | |
} |
func (r ServicebusNamespaceCustomerManagedKeyResource) userAssigned(data acceptance.TestData) string { | ||
return fmt.Sprintf(` | ||
%s | ||
|
||
resource "azurerm_servicebus_namespace_customer_managed_key" "test" { | ||
namespace_id = azurerm_servicebus_namespace.test.id | ||
key_vault_key_id = azurerm_key_vault_key.test.id | ||
identity_id = azurerm_user_assigned_identity.test.id | ||
infrastructure_encryption_enabled = true | ||
} | ||
`, r.templateUserAssigned(data)) | ||
} | ||
|
||
func (r ServicebusNamespaceCustomerManagedKeyResource) userAssignedUpdated(data acceptance.TestData) string { | ||
return fmt.Sprintf(` | ||
%s | ||
|
||
resource "azurerm_servicebus_namespace_customer_managed_key" "test" { | ||
namespace_id = azurerm_servicebus_namespace.test.id | ||
key_vault_key_id = azurerm_key_vault_key.test.id | ||
identity_id = azurerm_user_assigned_identity.test.id | ||
infrastructure_encryption_enabled = true | ||
} | ||
`, r.templateUserAssigned(data)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't tell the difference between these two configs, are they the same?
|
||
data.ResourceTest(t, r, []acceptance.TestStep{ | ||
{ | ||
Config: r.complete(data), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually use the basic config for the requires import check
Config: r.complete(data), | |
Config: r.basic(data), |
layout: "azurerm" | ||
page_title: "Azure Resource Manager: azurerm_servicebus_namespace" | ||
description: |- | ||
Manages a ServiceBus Namespace Customer Managed Key. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realise ServiceBus is written together as one word in a lot of our documentation, but I think this should actually be split into two words. Could you split it in this doc and we can update the others at a later point?
Manages a ServiceBus Namespace Customer Managed Key. | ||
|
||
!> **Note:** It is not possible to remove the Customer Managed Key from the ServiceBus Namespace once it's been added. To remove the Customer Managed Key, the parent ServiceBus Namespace must be deleted and recreated. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to warn users not to try and manage the CMK with both this resource and the block on the resource. We have this for other resources where something that can be configured in-line is also available as a virtual resource
~> **Note:** It's possible to define a Customer Managed Key both within [the `azurerm_servicebus_namespace` resource](servicebus_namespace.html) via the `customer_managed_key` block and by using this resource. It is not possible to use both methods to manage a Customer Managed Key for a Service Bus Namespace since it will result in a conflict. |
A note on the service bus namespace resource under the customer_managed_key
block informing users that they need to add this to ignore_changes
if they're using this resource to manage CMK might also be a good addition too.
Community Note
Description
This PR adds support for the new resource
azurerm_servicebus_namespace_customer_managed_key
PR Checklist
For example: “
resource_name_here
- description of change e.g. adding propertynew_property_name_here
”Testing
Change Log
Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.
azurerm_servicebus_namespace_customer_managed_key
[GH-00000]This is a (please select all that apply):
Related Issue(s)
Fixes #21313
Note
If this PR changes meaningfully during the course of review please update the title and description as required.