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_kusto_cluster_customer_managed_key - support auto key rotation #20583

Merged
merged 5 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
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 @@ -61,7 +61,7 @@ func resourceKustoClusterCustomerManagedKey() *pluginsdk.Resource {

"key_version": {
Type: pluginsdk.TypeString,
Required: true,
Optional: true,
ValidateFunc: validation.StringIsNotEmpty,
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,32 @@ func TestAccKustoClusterCustomerManagedKey_basic(t *testing.T) {
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("key_vault_id").Exists(),
check.That(data.ResourceName).Key("key_name").Exists(),
),
},
data.ImportStep(),
{
// Delete the encryption settings resource and verify it is gone
Config: r.template(data),
Check: acceptance.ComposeTestCheckFunc(
// Then ensure the encryption settings on the Kusto cluster
// have been reverted to their default state
check.That("azurerm_kusto_cluster.test").DoesNotExistInAzure(r),
),
},
})
}

func TestAccKustoClusterCustomerManagedKey_complete(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_kusto_cluster_customer_managed_key", "test")
r := KustoClusterCustomerManagedKeyResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.complete(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("key_vault_id").Exists(),
Expand All @@ -48,7 +74,7 @@ func TestAccKustoClusterCustomerManagedKey_requiresImport(t *testing.T) {

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Config: r.complete(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("key_vault_id").Exists(),
Expand All @@ -66,7 +92,7 @@ func TestAccKustoClusterCustomerManagedKey_updateKey(t *testing.T) {

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Config: r.complete(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("key_vault_id").Exists(),
Expand Down Expand Up @@ -123,6 +149,19 @@ func (KustoClusterCustomerManagedKeyResource) basic(data acceptance.TestData) st
return fmt.Sprintf(`
%s

resource "azurerm_kusto_cluster_customer_managed_key" "test" {
cluster_id = azurerm_kusto_cluster.test.id
key_vault_id = azurerm_key_vault.test.id
key_name = azurerm_key_vault_key.first.name
}
`, template)
}

func (KustoClusterCustomerManagedKeyResource) complete(data acceptance.TestData) string {
template := KustoClusterCustomerManagedKeyResource{}.template(data)
return fmt.Sprintf(`
%s

resource "azurerm_kusto_cluster_customer_managed_key" "test" {
cluster_id = azurerm_kusto_cluster.test.id
key_vault_id = azurerm_key_vault.test.id
Expand All @@ -141,7 +180,6 @@ resource "azurerm_kusto_cluster_customer_managed_key" "import" {
cluster_id = azurerm_kusto_cluster_customer_managed_key.test.cluster_id
key_vault_id = azurerm_kusto_cluster_customer_managed_key.test.key_vault_id
key_name = azurerm_kusto_cluster_customer_managed_key.test.key_name
key_version = azurerm_kusto_cluster_customer_managed_key.test.key_version
}
`, template)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ The following arguments are supported:

* `key_name` - (Required) The name of Key Vault Key.

* `key_version` - (Required) The version of Key Vault Key.
* `key_version` - (Optional) The version of Key Vault Key.

* `user_identity` - (Optional) The user assigned identity that has access to the Key Vault Key. If not specified, system assigned identity will be used.

Expand Down