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

Changes after first pull request #1

Merged
merged 8 commits into from
Oct 20, 2020
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
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@

IMPROVEMENTS:

* `azurerm_cosmosdb_sql_container` - support for composite indexes [GH-8792]
* `azurerm_mssql_database` - do not set longterm and shortterm retention policies when using the `DW` SKUs [GH-8899]
* `azurerm_search_service` - add support for `identity` [GH-8907]
* `azurerm_search_service` - support for the `identity` block [GH-8907]
* `azurerm_sql_firewall_rule` - adding validation for the `start_ip_address` and `end_ip_address` fields [GH-8935]

BUG FIXES:

* `azurerm_application_gateway` - now supports `ignore_changes` for `ssl_certificate` when using pre-existing certificates [GH-8761]
* `azurerm_policy_set_definition` - Fix updates for `parameters` and `parameter_values` in `policy_definition_reference` blocks [GH-8882]

## 2.32.0 (October 15, 2020)

Expand Down
62 changes: 62 additions & 0 deletions azurerm/internal/services/cosmos/common/indexing_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,27 @@ func expandAzureRmCosmosDBIndexingPolicyExcludedPaths(input []interface{}) *[]do
return &paths
}

func expandAzureRmCosmosDBIndexingPolicyCompositeIndexes(input []interface{}) *[][]documentdb.CompositePath {
indexes := make([][]documentdb.CompositePath, 0)

for _, i := range input {
indexPairs := make([]documentdb.CompositePath, 0)
indexPair := i.(map[string]interface{})
for _, idxPair := range indexPair["index"].([]interface{}) {
data := idxPair.(map[string]interface{})

index := documentdb.CompositePath{
Path: utils.String(data["path"].(string)),
Order: documentdb.CompositePathSortOrder(data["order"].(string)),
}
indexPairs = append(indexPairs, index)
}
indexes = append(indexes, indexPairs)
}

return &indexes
}

func ExpandAzureRmCosmosDbIndexingPolicy(d *schema.ResourceData) *documentdb.IndexingPolicy {
i := d.Get("indexing_policy").([]interface{})

Expand All @@ -60,6 +81,9 @@ func ExpandAzureRmCosmosDbIndexingPolicy(d *schema.ResourceData) *documentdb.Ind
policy.ExcludedPaths = expandAzureRmCosmosDBIndexingPolicyExcludedPaths(v)
}

if v, ok := input["composite_index"].([]interface{}); ok {
policy.CompositeIndexes = expandAzureRmCosmosDBIndexingPolicyCompositeIndexes(v)
}
return policy
}

Expand All @@ -85,6 +109,43 @@ func flattenCosmosDBIndexingPolicyExcludedPaths(input *[]documentdb.ExcludedPath
return excludedPaths
}

func flattenCosmosDBIndexingPolicyCompositeIndex(input []documentdb.CompositePath) []interface{} {
if input == nil {
return []interface{}{}
}

indexPairs := make([]interface{}, 0)
for _, v := range input {
path := ""
if v.Path != nil {
path = *v.Path
}

block := make(map[string]interface{})
block["path"] = path
block["order"] = string(v.Order)
indexPairs = append(indexPairs, block)
}

return indexPairs
}

func flattenCosmosDBIndexingPolicyCompositeIndexes(input *[][]documentdb.CompositePath) []interface{} {
if input == nil {
return []interface{}{}
}

indexes := make([]interface{}, 0)

for _, v := range *input {
block := make(map[string][]interface{})
block["index"] = flattenCosmosDBIndexingPolicyCompositeIndex(v)
indexes = append(indexes, block)
}

return indexes
}

func flattenCosmosDBIndexingPolicyIncludedPaths(input *[]documentdb.IncludedPath) []interface{} {
if input == nil {
return nil
Expand All @@ -111,6 +172,7 @@ func FlattenAzureRmCosmosDbIndexingPolicy(indexingPolicy *documentdb.IndexingPol
result["indexing_mode"] = string(indexingPolicy.IndexingMode)
result["included_path"] = flattenCosmosDBIndexingPolicyIncludedPaths(indexingPolicy.IncludedPaths)
result["excluded_path"] = flattenCosmosDBIndexingPolicyExcludedPaths(indexingPolicy.ExcludedPaths)
result["composite_index"] = flattenCosmosDBIndexingPolicyCompositeIndexes(indexingPolicy.CompositeIndexes)

results = append(results, result)
return results
Expand Down
33 changes: 33 additions & 0 deletions azurerm/internal/services/cosmos/common/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,39 @@ func CosmosDbIndexingPolicySchema() *schema.Schema {
},
},
},
"composite_index": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"index": {
Type: schema.TypeList,
MinItems: 1,
Required: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"path": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringIsNotEmpty,
},
"order": {
Type: schema.TypeString,
Required: true,
// Workaround for Azure/azure-rest-api-specs#11222
DiffSuppressFunc: suppress.CaseDifference,
ValidateFunc: validation.StringInSlice(
[]string{
string(documentdb.Ascending),
string(documentdb.Descending),
}, false),
},
},
},
},
},
},
},
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,27 @@ resource "azurerm_cosmosdb_sql_container" "test" {
excluded_path {
path = "/testing/id2/*"
}
composite_index {
index {
path = "/path1"
order = "Descending"
}
index {
path = "/path2"
order = "Ascending"
}
}

composite_index {
index {
path = "/path3"
order = "Ascending"
}
index {
path = "/path4"
order = "Descending"
}
}
}
}
`, testAccAzureRMCosmosDbSqlDatabase_basic(data), data.RandomInteger)
Expand Down Expand Up @@ -293,6 +314,28 @@ resource "azurerm_cosmosdb_sql_container" "test" {
excluded_path {
path = "/testing/id1/*"
}

composite_index {
index {
path = "/path1"
order = "Ascending"
}
index {
path = "/path2"
order = "Descending"
}
}

composite_index {
index {
path = "/path3"
order = "Ascending"
}
index {
path = "/path4"
order = "Descending"
}
}
}
}
`, testAccAzureRMCosmosDbSqlDatabase_basic(data), data.RandomInteger)
Expand Down Expand Up @@ -338,6 +381,28 @@ resource "azurerm_cosmosdb_sql_container" "test" {
excluded_path {
path = "%s"
}

composite_index {
index {
path = "/path1"
order = "Ascending"
}
index {
path = "/path2"
order = "Descending"
}
}

composite_index {
index {
path = "/path3"
order = "Ascending"
}
index {
path = "/path4"
order = "Descending"
}
}
}
}
`, testAccAzureRMCosmosDbSqlDatabase_basic(data), data.RandomInteger, includedPath, excludedPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3243,6 +3243,7 @@ func expandApplicationGatewaySslCertificates(d *schema.ResourceData) (*[]network
data := v["data"].(string)
password := v["password"].(string)
kvsid := v["key_vault_secret_id"].(string)
cert := v["public_cert_data"].(string)

output := network.ApplicationGatewaySslCertificate{
Name: utils.String(name),
Expand All @@ -3263,6 +3264,8 @@ func expandApplicationGatewaySslCertificates(d *schema.ResourceData) (*[]network
}

output.ApplicationGatewaySslCertificatePropertiesFormat.KeyVaultSecretID = utils.String(kvsid)
} else if cert != "" {
output.ApplicationGatewaySslCertificatePropertiesFormat.PublicCertData = utils.String(cert)
} else {
return nil, fmt.Errorf("either `key_vault_secret_id` or `data` must be specified for the `ssl_certificate` block %q", name)
}
Expand Down
Loading