Skip to content

Commit

Permalink
Merge pull request hashicorp#26055 from hashicorp/t/eh-cmk-test-optim…
Browse files Browse the repository at this point in the history
…isation

`azurerm_eventhub_namespace_customer_managed_key` - drop tests from cluster to premium SKU
  • Loading branch information
jackofallops authored May 22, 2024
2 parents 1116634 + b61c4ef commit 2085032
Showing 1 changed file with 31 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,32 +208,20 @@ resource "azurerm_eventhub_namespace_customer_managed_key" "test" {
func (r EventHubNamespaceCustomerManagedKeyResource) template(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {
key_vault {
purge_soft_delete_on_destroy = false
purge_soft_deleted_keys_on_destroy = false
}
}
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-namespacecmk-%d"
location = "%s"
}
resource "azurerm_eventhub_cluster" "test" {
name = "acctest-cluster-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
sku_name = "Dedicated_1"
name = "acctestRG-namespacecmk-%[1]d"
location = "%[2]s"
}
resource "azurerm_eventhub_namespace" "test" {
name = "acctest-namespace-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku = "Standard"
dedicated_cluster_id = azurerm_eventhub_cluster.test.id
name = "acctest-namespace-%[1]d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku = "Premium"
zone_redundant = true
identity {
type = "SystemAssigned"
Expand All @@ -243,12 +231,11 @@ resource "azurerm_eventhub_namespace" "test" {
data "azurerm_client_config" "current" {}
resource "azurerm_key_vault" "test" {
name = "acctestkv%s"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
tenant_id = data.azurerm_client_config.current.tenant_id
sku_name = "standard"
purge_protection_enabled = true
name = "acctestkv%[2]s"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
tenant_id = data.azurerm_client_config.current.tenant_id
sku_name = "standard"
}
resource "azurerm_key_vault_access_policy" "test" {
Expand Down Expand Up @@ -276,7 +263,7 @@ resource "azurerm_key_vault_access_policy" "test2" {
}
resource "azurerm_key_vault_key" "test" {
name = "acctestkvkey%s"
name = "acctestkvkey%[2]s"
key_vault_id = azurerm_key_vault.test.id
key_type = "RSA"
key_size = 2048
Expand All @@ -287,44 +274,32 @@ resource "azurerm_key_vault_key" "test" {
azurerm_key_vault_access_policy.test2,
]
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomString, data.RandomString)
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}

func (r EventHubNamespaceCustomerManagedKeyResource) templateWithUserAssignedIdentity(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {
key_vault {
purge_soft_delete_on_destroy = false
purge_soft_deleted_keys_on_destroy = false
}
}
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-namespacecmk-%d"
location = "%s"
}
resource "azurerm_eventhub_cluster" "test" {
name = "acctest-cluster-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
sku_name = "Dedicated_1"
name = "acctestRG-namespacecmk-%[1]d"
location = "%[2]s"
}
resource "azurerm_user_assigned_identity" "test" {
location = azurerm_resource_group.test.location
name = "acctest-identity-%s"
name = "acctest-identity-%[3]s"
resource_group_name = azurerm_resource_group.test.name
}
resource "azurerm_eventhub_namespace" "test" {
name = "acctest-namespace-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku = "Standard"
dedicated_cluster_id = azurerm_eventhub_cluster.test.id
name = "acctest-namespace-%[1]d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku = "Premium"
zone_redundant = true
identity {
type = "UserAssigned"
Expand All @@ -335,12 +310,11 @@ resource "azurerm_eventhub_namespace" "test" {
data "azurerm_client_config" "current" {}
resource "azurerm_key_vault" "test" {
name = "acctestkv%s"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
tenant_id = data.azurerm_client_config.current.tenant_id
sku_name = "standard"
purge_protection_enabled = true
name = "acctestkv%[3]s"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
tenant_id = data.azurerm_client_config.current.tenant_id
sku_name = "standard"
}
resource "azurerm_key_vault_access_policy" "test" {
Expand Down Expand Up @@ -368,7 +342,7 @@ resource "azurerm_key_vault_access_policy" "test2" {
}
resource "azurerm_key_vault_key" "test" {
name = "acctestkvkey%s"
name = "acctestkvkey%[3]s"
key_vault_id = azurerm_key_vault.test.id
key_type = "RSA"
key_size = 2048
Expand All @@ -379,5 +353,5 @@ resource "azurerm_key_vault_key" "test" {
azurerm_key_vault_access_policy.test2,
]
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomString, data.RandomInteger, data.RandomString, data.RandomString)
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}

0 comments on commit 2085032

Please sign in to comment.