provider/azurerm: Add documentation for the `azurerm_search_service`
resource
This commit is contained in:
parent
dbc5464a19
commit
3eab9f2ff0
|
@ -74,6 +74,7 @@ func Provider() terraform.ResourceProvider {
|
||||||
"azurerm_sql_server": resourceArmSqlServer(),
|
"azurerm_sql_server": resourceArmSqlServer(),
|
||||||
"azurerm_sql_database": resourceArmSqlDatabase(),
|
"azurerm_sql_database": resourceArmSqlDatabase(),
|
||||||
"azurerm_sql_firewall_rule": resourceArmSqlFirewallRule(),
|
"azurerm_sql_firewall_rule": resourceArmSqlFirewallRule(),
|
||||||
|
"azurerm_search_service": resourceArmSearchService(),
|
||||||
},
|
},
|
||||||
ConfigureFunc: providerConfigure,
|
ConfigureFunc: providerConfigure,
|
||||||
}
|
}
|
||||||
|
@ -141,7 +142,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
|
||||||
func registerAzureResourceProvidersWithSubscription(config *Config, client *ArmClient) error {
|
func registerAzureResourceProvidersWithSubscription(config *Config, client *ArmClient) error {
|
||||||
providerClient := client.providers
|
providerClient := client.providers
|
||||||
|
|
||||||
providers := []string{"Microsoft.Network", "Microsoft.Compute", "Microsoft.Cdn", "Microsoft.Storage", "Microsoft.Sql"}
|
providers := []string{"Microsoft.Network", "Microsoft.Compute", "Microsoft.Cdn", "Microsoft.Storage", "Microsoft.Sql", "Microsoft.Search"}
|
||||||
|
|
||||||
for _, v := range providers {
|
for _, v := range providers {
|
||||||
res, err := providerClient.Register(v)
|
res, err := providerClient.Register(v)
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
"github.com/jen20/riviera/azure"
|
|
||||||
"github.com/jen20/riviera/search"
|
"github.com/jen20/riviera/search"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -78,11 +77,13 @@ func resourceArmSearchServiceCreate(d *schema.ResourceData, meta interface{}) er
|
||||||
}
|
}
|
||||||
|
|
||||||
if v, ok := d.GetOk("replica_count"); ok {
|
if v, ok := d.GetOk("replica_count"); ok {
|
||||||
command.ReplicaCount = azure.String(v.(string))
|
replica_count := v.(int)
|
||||||
|
command.ReplicaCount = &replica_count
|
||||||
}
|
}
|
||||||
|
|
||||||
if v, ok := d.GetOk("partition_count"); ok {
|
if v, ok := d.GetOk("partition_count"); ok {
|
||||||
command.PartitionCount = azure.String(v.(string))
|
partition_count := v.(int)
|
||||||
|
command.PartitionCount = &partition_count
|
||||||
}
|
}
|
||||||
|
|
||||||
createRequest := rivieraClient.NewRequest()
|
createRequest := rivieraClient.NewRequest()
|
||||||
|
@ -119,7 +120,8 @@ func resourceArmSearchServiceCreate(d *schema.ResourceData, meta interface{}) er
|
||||||
Target: []string{"succeeded"},
|
Target: []string{"succeeded"},
|
||||||
Refresh: azureStateRefreshFunc(*resp.ID, client, getSearchServiceCommand),
|
Refresh: azureStateRefreshFunc(*resp.ID, client, getSearchServiceCommand),
|
||||||
// ¯\_(ツ)_/¯
|
// ¯\_(ツ)_/¯
|
||||||
Timeout: 30 * time.Minute,
|
Timeout: 30 * time.Minute,
|
||||||
|
MinTimeout: 15 * time.Second,
|
||||||
}
|
}
|
||||||
if _, err := stateConf.WaitForState(); err != nil {
|
if _, err := stateConf.WaitForState(); err != nil {
|
||||||
return fmt.Errorf("Error waiting for Search Service (%s) to become available: %s", d.Get("name"), err)
|
return fmt.Errorf("Error waiting for Search Service (%s) to become available: %s", d.Get("name"), err)
|
||||||
|
@ -149,6 +151,12 @@ func resourceArmSearchServiceRead(d *schema.ResourceData, meta interface{}) erro
|
||||||
|
|
||||||
resp := readResponse.Parsed.(*search.GetSearchServiceResponse)
|
resp := readResponse.Parsed.(*search.GetSearchServiceResponse)
|
||||||
d.Set("sku", resp.Sku)
|
d.Set("sku", resp.Sku)
|
||||||
|
if resp.PartitionCount != nil {
|
||||||
|
d.Set("partition_count", resp.PartitionCount)
|
||||||
|
}
|
||||||
|
if resp.ReplicaCount != nil {
|
||||||
|
d.Set("replica_count", resp.ReplicaCount)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,42 +23,48 @@ func TestAccAzureRMSearchService_basic(t *testing.T) {
|
||||||
Config: config,
|
Config: config,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testCheckAzureRMSearchServiceExists("azurerm_search_service.test"),
|
testCheckAzureRMSearchServiceExists("azurerm_search_service.test"),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"azurerm_search_service.test", "tags.#", "2"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//func TestAccAzureRMSearchService_withTags(t *testing.T) {
|
func TestAccAzureRMSearchService_updateReplicaCountAndTags(t *testing.T) {
|
||||||
// ri := acctest.RandInt()
|
ri := acctest.RandInt()
|
||||||
// preConfig := fmt.Sprintf(testAccAzureRMSearchService_withTags, ri, ri)
|
preConfig := fmt.Sprintf(testAccAzureRMSearchService_basic, ri, ri)
|
||||||
// postConfig := fmt.Sprintf(testAccAzureRMSearchService_withTagsUpdated, ri, ri)
|
postConfig := fmt.Sprintf(testAccAzureRMSearchService_updated, ri, ri)
|
||||||
//
|
|
||||||
// resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
// PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
// Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
// CheckDestroy: testCheckAzureRMSearchServiceDestroy,
|
CheckDestroy: testCheckAzureRMSearchServiceDestroy,
|
||||||
// Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
// resource.TestStep{
|
resource.TestStep{
|
||||||
// Config: preConfig,
|
Config: preConfig,
|
||||||
// Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
// testCheckAzureRMSearchServiceExists("azurerm_search_service.test"),
|
testCheckAzureRMSearchServiceExists("azurerm_search_service.test"),
|
||||||
// resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
// "azurerm_search_service.test", "tags.#", "2"),
|
"azurerm_search_service.test", "tags.#", "2"),
|
||||||
// ),
|
resource.TestCheckResourceAttr(
|
||||||
// },
|
"azurerm_search_service.test", "replica_count", "1"),
|
||||||
//
|
),
|
||||||
// resource.TestStep{
|
},
|
||||||
// Config: postConfig,
|
|
||||||
// Check: resource.ComposeTestCheckFunc(
|
resource.TestStep{
|
||||||
// testCheckAzureRMSearchServiceExists("azurerm_search_service.test"),
|
Config: postConfig,
|
||||||
// resource.TestCheckResourceAttr(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
// "azurerm_search_service.test", "tags.#", "1"),
|
testCheckAzureRMSearchServiceExists("azurerm_search_service.test"),
|
||||||
// ),
|
resource.TestCheckResourceAttr(
|
||||||
// },
|
"azurerm_search_service.test", "tags.#", "1"),
|
||||||
// },
|
resource.TestCheckResourceAttr(
|
||||||
// })
|
"azurerm_search_service.test", "replica_count", "2"),
|
||||||
//}
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func testCheckAzureRMSearchServiceExists(name string) resource.TestCheckFunc {
|
func testCheckAzureRMSearchServiceExists(name string) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
|
@ -119,44 +125,28 @@ resource "azurerm_search_service" "test" {
|
||||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||||
location = "West US"
|
location = "West US"
|
||||||
sku = "standard"
|
sku = "standard"
|
||||||
|
|
||||||
|
tags {
|
||||||
|
environment = "staging"
|
||||||
|
database = "test"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
//var testAccAzureRMSearchService_withTags = `
|
var testAccAzureRMSearchService_updated = `
|
||||||
//resource "azurerm_resource_group" "test" {
|
resource "azurerm_resource_group" "test" {
|
||||||
// name = "acctest_rg_%d"
|
name = "acctest_rg_%d"
|
||||||
// location = "West US"
|
location = "West US"
|
||||||
//}
|
}
|
||||||
//resource "azurerm_sql_server" "test" {
|
resource "azurerm_search_service" "test" {
|
||||||
// name = "acctestsqlserver%d"
|
name = "acctestsearchservice%d"
|
||||||
// resource_group_name = "${azurerm_resource_group.test.name}"
|
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||||
// location = "West US"
|
location = "West US"
|
||||||
// version = "12.0"
|
sku = "standard"
|
||||||
// administrator_login = "mradministrator"
|
replica_count = 2
|
||||||
// administrator_login_password = "thisIsDog11"
|
|
||||||
//
|
tags {
|
||||||
// tags {
|
environment = "production"
|
||||||
// environment = "staging"
|
}
|
||||||
// database = "test"
|
}
|
||||||
// }
|
`
|
||||||
//}
|
|
||||||
//`
|
|
||||||
//
|
|
||||||
//var testAccAzureRMSearchService_withTagsUpdated = `
|
|
||||||
//resource "azurerm_resource_group" "test" {
|
|
||||||
// name = "acctest_rg_%d"
|
|
||||||
// location = "West US"
|
|
||||||
//}
|
|
||||||
//resource "azurerm_sql_server" "test" {
|
|
||||||
// name = "acctestsqlserver%d"
|
|
||||||
// resource_group_name = "${azurerm_resource_group.test.name}"
|
|
||||||
// location = "West US"
|
|
||||||
// version = "12.0"
|
|
||||||
// administrator_login = "mradministrator"
|
|
||||||
// administrator_login_password = "thisIsDog11"
|
|
||||||
//
|
|
||||||
// tags {
|
|
||||||
// environment = "production"
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//`
|
|
||||||
|
|
|
@ -11,9 +11,9 @@ type CreateOrUpdateSearchServiceResponse struct {
|
||||||
Name *string `mapstructure:"name"`
|
Name *string `mapstructure:"name"`
|
||||||
Location *string `mapstructure:"location"`
|
Location *string `mapstructure:"location"`
|
||||||
Tags *map[string]*string `mapstructure:"tags"`
|
Tags *map[string]*string `mapstructure:"tags"`
|
||||||
Sku *Sku `json:"sku,omitempty"`
|
Sku *Sku `mapstructure:"sku"`
|
||||||
ReplicaCount *string `json:"replicaCount,omitempty"`
|
ReplicaCount *int `mapstructure:"replicaCount"`
|
||||||
PartitionCount *string `json:"partitionCount,omitempty"`
|
PartitionCount *int `mapstructure:"partitionCount"`
|
||||||
Status *string `mapstructure:"status"`
|
Status *string `mapstructure:"status"`
|
||||||
StatusDetails *string `mapstructure:"statusDetails"`
|
StatusDetails *string `mapstructure:"statusDetails"`
|
||||||
ProvisioningStatus *string `mapstructure:"provisioningStatus"`
|
ProvisioningStatus *string `mapstructure:"provisioningStatus"`
|
||||||
|
@ -25,8 +25,8 @@ type CreateOrUpdateSearchService struct {
|
||||||
Location string `json:"-" riviera:"location"`
|
Location string `json:"-" riviera:"location"`
|
||||||
Tags map[string]*string `json:"-" riviera:"tags"`
|
Tags map[string]*string `json:"-" riviera:"tags"`
|
||||||
Sku Sku `json:"-" riviera:"sku"`
|
Sku Sku `json:"-" riviera:"sku"`
|
||||||
ReplicaCount *string `json:"replicaCount,omitempty"`
|
ReplicaCount *int `json:"replicaCount,omitempty"`
|
||||||
PartitionCount *string `json:"partitionCount,omitempty"`
|
PartitionCount *int `json:"partitionCount,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s CreateOrUpdateSearchService) APIInfo() azure.APIInfo {
|
func (s CreateOrUpdateSearchService) APIInfo() azure.APIInfo {
|
||||||
|
|
|
@ -4,13 +4,13 @@ import "github.com/jen20/riviera/azure"
|
||||||
|
|
||||||
type GetSearchServiceResponse struct {
|
type GetSearchServiceResponse struct {
|
||||||
ID *string `mapstructure:"id"`
|
ID *string `mapstructure:"id"`
|
||||||
Name string `json:"-"`
|
Name string `mapstructure:"name"`
|
||||||
ResourceGroupName string `json:"-"`
|
ResourceGroupName string `mapstructure:"-"`
|
||||||
Location string `json:"-" riviera:"location"`
|
Location string `mapstructure:"location"`
|
||||||
Tags map[string]*string `json:"-" riviera:"tags"`
|
Tags map[string]*string `mapstructure:"tags"`
|
||||||
Sku *Sku `json:"sku,omitempty"`
|
Sku *Sku `mapstructure:"sku"`
|
||||||
ReplicaCount *string `json:"replicaCount,omitempty"`
|
ReplicaCount *int `mapstructure:"replicaCount"`
|
||||||
PartitionCount *string `json:"partitionCount,omitempty"`
|
PartitionCount *int `mapstructure:"partitionCount"`
|
||||||
Status *string `mapstructure:"status"`
|
Status *string `mapstructure:"status"`
|
||||||
StatusDetails *string `mapstructure:"statusDetails"`
|
StatusDetails *string `mapstructure:"statusDetails"`
|
||||||
ProvisioningState *string `mapstructure:"provisioningState"`
|
ProvisioningState *string `mapstructure:"provisioningState"`
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
---
|
||||||
|
layout: "azurerm"
|
||||||
|
page_title: "Azure Resource Manager: azurerm_search_service"
|
||||||
|
sidebar_current: "docs-azurerm-resource-search-service"
|
||||||
|
description: |-
|
||||||
|
Manage a Search Service.
|
||||||
|
---
|
||||||
|
|
||||||
|
# azurerm\_search\_service
|
||||||
|
|
||||||
|
Allows you to manage an Azure Search Service
|
||||||
|
|
||||||
|
## Example Usage
|
||||||
|
|
||||||
|
```
|
||||||
|
resource "azurerm_resource_group" "test" {
|
||||||
|
name = "acceptanceTestResourceGroup1"
|
||||||
|
location = "West US"
|
||||||
|
}
|
||||||
|
resource "azurerm_search_service" "test" {
|
||||||
|
name = "acceptanceTestSearchService1"
|
||||||
|
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||||
|
location = "West US"
|
||||||
|
sku = "standard"
|
||||||
|
|
||||||
|
tags {
|
||||||
|
environment = "staging"
|
||||||
|
database = "test"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
## Argument Reference
|
||||||
|
|
||||||
|
The following arguments are supported:
|
||||||
|
|
||||||
|
* `name` - (Required) The name of the Search Service.
|
||||||
|
|
||||||
|
* `resource_group_name` - (Required) The name of the resource group in which to
|
||||||
|
create the Search Service.
|
||||||
|
|
||||||
|
* `location` - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.
|
||||||
|
|
||||||
|
* `sku` - (Required) Valid values are `free` and `standard`. `standard2` is also valid, but can only be used when it's enabled on the backend by Microsoft support. `free` provisions the service in shared clusters. `standard` provisions the service in dedicated clusters
|
||||||
|
|
||||||
|
* `replica_count` - (Optional) Default is 1. Valid values include 1 through 12. Valid only when `sku` is `standard`.
|
||||||
|
|
||||||
|
* `partition_count` - (Optional) Default is 1. Valid values include 1, 2, 3, 4, 6, or 12. Valid only when `sku` is `standard`.
|
||||||
|
|
||||||
|
* `tags` - (Optional) A mapping of tags to assign to the resource.
|
||||||
|
|
||||||
|
## Attributes Reference
|
||||||
|
|
||||||
|
The following attributes are exported:
|
||||||
|
|
||||||
|
* `id` - The Search Service ID.
|
|
@ -112,6 +112,15 @@
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<li<%= sidebar_current(/^docs-azurerm-resource-search/) %>>
|
||||||
|
<a href="#">Search Resources</a>
|
||||||
|
<ul class="nav nav-visible">
|
||||||
|
<li<%= sidebar_current("docs-azurerm-resource-search-service") %>>
|
||||||
|
<a href="/docs/providers/azurerm/r/search_service.html">azurerm_search_service</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
|
||||||
<li<%= sidebar_current(/^docs-azurerm-resource-sql/) %>>
|
<li<%= sidebar_current(/^docs-azurerm-resource-sql/) %>>
|
||||||
<a href="#">SQL Resources</a>
|
<a href="#">SQL Resources</a>
|
||||||
<ul class="nav nav-visible">
|
<ul class="nav nav-visible">
|
||||||
|
|
Loading…
Reference in New Issue