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

Event Hub: force new on partition count change #2400

Merged
merged 1 commit into from Nov 28, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion azurerm/resource_arm_eventhub.go
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/suppress"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

Expand Down Expand Up @@ -46,6 +47,7 @@ func resourceArmEventHub() *schema.Resource {
"partition_count": {
Type: schema.TypeInt,
Required: true,
ForceNew: true,
ValidateFunc: validateEventHubPartitionCount,
},

Expand All @@ -68,7 +70,7 @@ func resourceArmEventHub() *schema.Resource {
"encoding": {
Type: schema.TypeString,
Required: true,
DiffSuppressFunc: ignoreCaseDiffSuppressFunc,
DiffSuppressFunc: suppress.CaseDifference,
ValidateFunc: validation.StringInSlice([]string{
string(eventhub.Avro),
string(eventhub.AvroDeflate),
Expand Down
53 changes: 53 additions & 0 deletions azurerm/resource_arm_eventhub_test.go
Expand Up @@ -188,6 +188,35 @@ func TestAccAzureRMEventHub_basic(t *testing.T) {
})
}

func TestAccAzureRMEventHub_partitionCountUpdate(t *testing.T) {
resourceName := "azurerm_eventhub.test"
ri := acctest.RandInt()
preConfig := testAccAzureRMEventHub_basic(ri, testLocation())
postConfig := testAccAzureRMEventHub_partitionCountUpdate(ri, testLocation())

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMEventHubDestroy,
Steps: []resource.TestStep{
{
Config: preConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMEventHubExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "partition_count", "2"),
),
},
{
Config: postConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMEventHubExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "partition_count", "10"),
),
},
},
})
}

func TestAccAzureRMEventHub_standard(t *testing.T) {
resourceName := "azurerm_eventhub.test"
ri := acctest.RandInt()
Expand Down Expand Up @@ -381,6 +410,30 @@ resource "azurerm_eventhub" "test" {
`, rInt, location, rInt, rInt)
}

func testAccAzureRMEventHub_partitionCountUpdate(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}

resource "azurerm_eventhub_namespace" "test" {
name = "acctesteventhubnamespace-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
sku = "Basic"
}

resource "azurerm_eventhub" "test" {
name = "acctesteventhub-%d"
namespace_name = "${azurerm_eventhub_namespace.test.name}"
resource_group_name = "${azurerm_resource_group.test.name}"
partition_count = 10
message_retention = 1
}
`, rInt, location, rInt, rInt)
}

func testAccAzureRMEventHub_standard(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/eventhub.html.markdown
Expand Up @@ -49,7 +49,7 @@ The following arguments are supported:

* `resource_group_name` - (Required) The name of the resource group in which the EventHub's parent Namespace exists. Changing this forces a new resource to be created.

* `partition_count` - (Required) Specifies the current number of shards on the Event Hub.
* `partition_count` - (Required) Specifies the current number of shards on the Event Hub. Changing this forces a new resource to be created.

* `message_retention` - (Required) Specifies the number of days to retain the events for this Event Hub. Needs to be between 1 and 7 days; or 1 day when using a Basic SKU for the parent EventHub Namespace.

Expand Down