From e4f8ab22554e3d49875709b6d954ff738a8d1321 Mon Sep 17 00:00:00 2001 From: "Andreas.Abdi" Date: Fri, 2 Nov 2018 16:43:47 -0700 Subject: [PATCH] Modify valid CIDR regex for azurerm cosmosdb account ip_range_filter Add /30 - /32 as allowed number of bits in network address inside of ip_range_filter. Modify the acceptance tests to validate against such an address. --- azurerm/resource_arm_cosmos_db_account.go | 2 +- azurerm/resource_arm_cosmos_db_account_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/azurerm/resource_arm_cosmos_db_account.go b/azurerm/resource_arm_cosmos_db_account.go index 23637ab09f96..a0e91a97efa9 100644 --- a/azurerm/resource_arm_cosmos_db_account.go +++ b/azurerm/resource_arm_cosmos_db_account.go @@ -74,7 +74,7 @@ func resourceArmCosmosDBAccount() *schema.Resource { Type: schema.TypeString, Optional: true, ValidateFunc: validation.StringMatch( - regexp.MustCompile(`^(\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/[1-2][0-9])?\b[,]?){1,}$`), + regexp.MustCompile(`^(\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/([1-2][0-9]|3[0-2]))?\b[,]?){1,}$`), "Cosmos DB ip_range_filter must be a set of CIDR IP addresses separated by commas with no spaces: '10.0.0.1,10.0.0.2,10.20.0.0/16'", ), }, diff --git a/azurerm/resource_arm_cosmos_db_account_test.go b/azurerm/resource_arm_cosmos_db_account_test.go index 694243b3c233..5c6da18e3b96 100644 --- a/azurerm/resource_arm_cosmos_db_account_test.go +++ b/azurerm/resource_arm_cosmos_db_account_test.go @@ -465,7 +465,7 @@ func TestAccAzureRMCosmosDBAccount_complete(t *testing.T) { Config: testAccAzureRMCosmosDBAccount_complete(ri, testLocation(), testAltLocation()), Check: resource.ComposeAggregateTestCheckFunc( checkAccAzureRMCosmosDBAccount_basic(resourceName, testLocation(), string(documentdb.BoundedStaleness), 2), - resource.TestCheckResourceAttr(resourceName, "ip_range_filter", "104.42.195.92,40.76.54.131,52.176.6.30,52.169.50.45,52.187.184.26,10.20.0.0/16"), + resource.TestCheckResourceAttr(resourceName, "ip_range_filter", "104.42.195.92,40.76.54.131,52.176.6.30,52.169.50.45/32,52.187.184.26,10.20.0.0/16"), resource.TestCheckResourceAttr(resourceName, "enable_automatic_failover", "true"), ), }, @@ -657,7 +657,7 @@ func testAccAzureRMCosmosDBAccount_geoReplicated_customId(rInt int, location str func testAccAzureRMCosmosDBAccount_complete(rInt int, location string, altLocation string) string { return testAccAzureRMCosmosDBAccount_basic(rInt, location, string(documentdb.BoundedStaleness), "", fmt.Sprintf(` - ip_range_filter = "104.42.195.92,40.76.54.131,52.176.6.30,52.169.50.45,52.187.184.26,10.20.0.0/16" + ip_range_filter = "104.42.195.92,40.76.54.131,52.176.6.30,52.169.50.45/32,52.187.184.26,10.20.0.0/16" enable_automatic_failover = true geo_location {