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_database": resourceArmSqlDatabase(),
|
||||
"azurerm_sql_firewall_rule": resourceArmSqlFirewallRule(),
|
||||
"azurerm_search_service": resourceArmSearchService(),
|
||||
},
|
||||
ConfigureFunc: providerConfigure,
|
||||
}
|
||||
|
@ -141,7 +142,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
|
|||
func registerAzureResourceProvidersWithSubscription(config *Config, client *ArmClient) error {
|
||||
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 {
|
||||
res, err := providerClient.Register(v)
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
"github.com/jen20/riviera/azure"
|
||||
"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 {
|
||||
command.ReplicaCount = azure.String(v.(string))
|
||||
replica_count := v.(int)
|
||||
command.ReplicaCount = &replica_count
|
||||
}
|
||||
|
||||
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()
|
||||
|
@ -119,7 +120,8 @@ func resourceArmSearchServiceCreate(d *schema.ResourceData, meta interface{}) er
|
|||
Target: []string{"succeeded"},
|
||||
Refresh: azureStateRefreshFunc(*resp.ID, client, getSearchServiceCommand),
|
||||
// ¯\_(ツ)_/¯
|
||||
Timeout: 30 * time.Minute,
|
||||
Timeout: 30 * time.Minute,
|
||||
MinTimeout: 15 * time.Second,
|
||||
}
|
||||
if _, err := stateConf.WaitForState(); err != nil {
|
||||
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)
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -23,42 +23,48 @@ func TestAccAzureRMSearchService_basic(t *testing.T) {
|
|||
Config: config,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testCheckAzureRMSearchServiceExists("azurerm_search_service.test"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"azurerm_search_service.test", "tags.#", "2"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//func TestAccAzureRMSearchService_withTags(t *testing.T) {
|
||||
// ri := acctest.RandInt()
|
||||
// preConfig := fmt.Sprintf(testAccAzureRMSearchService_withTags, ri, ri)
|
||||
// postConfig := fmt.Sprintf(testAccAzureRMSearchService_withTagsUpdated, ri, ri)
|
||||
//
|
||||
// resource.Test(t, resource.TestCase{
|
||||
// PreCheck: func() { testAccPreCheck(t) },
|
||||
// Providers: testAccProviders,
|
||||
// CheckDestroy: testCheckAzureRMSearchServiceDestroy,
|
||||
// Steps: []resource.TestStep{
|
||||
// resource.TestStep{
|
||||
// Config: preConfig,
|
||||
// Check: resource.ComposeTestCheckFunc(
|
||||
// testCheckAzureRMSearchServiceExists("azurerm_search_service.test"),
|
||||
// resource.TestCheckResourceAttr(
|
||||
// "azurerm_search_service.test", "tags.#", "2"),
|
||||
// ),
|
||||
// },
|
||||
//
|
||||
// resource.TestStep{
|
||||
// Config: postConfig,
|
||||
// Check: resource.ComposeTestCheckFunc(
|
||||
// testCheckAzureRMSearchServiceExists("azurerm_search_service.test"),
|
||||
// resource.TestCheckResourceAttr(
|
||||
// "azurerm_search_service.test", "tags.#", "1"),
|
||||
// ),
|
||||
// },
|
||||
// },
|
||||
// })
|
||||
//}
|
||||
func TestAccAzureRMSearchService_updateReplicaCountAndTags(t *testing.T) {
|
||||
ri := acctest.RandInt()
|
||||
preConfig := fmt.Sprintf(testAccAzureRMSearchService_basic, ri, ri)
|
||||
postConfig := fmt.Sprintf(testAccAzureRMSearchService_updated, ri, ri)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testCheckAzureRMSearchServiceDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: preConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testCheckAzureRMSearchServiceExists("azurerm_search_service.test"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"azurerm_search_service.test", "tags.#", "2"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"azurerm_search_service.test", "replica_count", "1"),
|
||||
),
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
Config: postConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
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 {
|
||||
return func(s *terraform.State) error {
|
||||
|
@ -119,44 +125,28 @@ resource "azurerm_search_service" "test" {
|
|||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
location = "West US"
|
||||
sku = "standard"
|
||||
|
||||
tags {
|
||||
environment = "staging"
|
||||
database = "test"
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
//var testAccAzureRMSearchService_withTags = `
|
||||
//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 = "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"
|
||||
// }
|
||||
//}
|
||||
//`
|
||||
var testAccAzureRMSearchService_updated = `
|
||||
resource "azurerm_resource_group" "test" {
|
||||
name = "acctest_rg_%d"
|
||||
location = "West US"
|
||||
}
|
||||
resource "azurerm_search_service" "test" {
|
||||
name = "acctestsearchservice%d"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
location = "West US"
|
||||
sku = "standard"
|
||||
replica_count = 2
|
||||
|
||||
tags {
|
||||
environment = "production"
|
||||
}
|
||||
}
|
||||
`
|
||||
|
|
|
@ -11,9 +11,9 @@ type CreateOrUpdateSearchServiceResponse struct {
|
|||
Name *string `mapstructure:"name"`
|
||||
Location *string `mapstructure:"location"`
|
||||
Tags *map[string]*string `mapstructure:"tags"`
|
||||
Sku *Sku `json:"sku,omitempty"`
|
||||
ReplicaCount *string `json:"replicaCount,omitempty"`
|
||||
PartitionCount *string `json:"partitionCount,omitempty"`
|
||||
Sku *Sku `mapstructure:"sku"`
|
||||
ReplicaCount *int `mapstructure:"replicaCount"`
|
||||
PartitionCount *int `mapstructure:"partitionCount"`
|
||||
Status *string `mapstructure:"status"`
|
||||
StatusDetails *string `mapstructure:"statusDetails"`
|
||||
ProvisioningStatus *string `mapstructure:"provisioningStatus"`
|
||||
|
@ -25,8 +25,8 @@ type CreateOrUpdateSearchService struct {
|
|||
Location string `json:"-" riviera:"location"`
|
||||
Tags map[string]*string `json:"-" riviera:"tags"`
|
||||
Sku Sku `json:"-" riviera:"sku"`
|
||||
ReplicaCount *string `json:"replicaCount,omitempty"`
|
||||
PartitionCount *string `json:"partitionCount,omitempty"`
|
||||
ReplicaCount *int `json:"replicaCount,omitempty"`
|
||||
PartitionCount *int `json:"partitionCount,omitempty"`
|
||||
}
|
||||
|
||||
func (s CreateOrUpdateSearchService) APIInfo() azure.APIInfo {
|
||||
|
|
|
@ -4,13 +4,13 @@ import "github.com/jen20/riviera/azure"
|
|||
|
||||
type GetSearchServiceResponse struct {
|
||||
ID *string `mapstructure:"id"`
|
||||
Name string `json:"-"`
|
||||
ResourceGroupName string `json:"-"`
|
||||
Location string `json:"-" riviera:"location"`
|
||||
Tags map[string]*string `json:"-" riviera:"tags"`
|
||||
Sku *Sku `json:"sku,omitempty"`
|
||||
ReplicaCount *string `json:"replicaCount,omitempty"`
|
||||
PartitionCount *string `json:"partitionCount,omitempty"`
|
||||
Name string `mapstructure:"name"`
|
||||
ResourceGroupName string `mapstructure:"-"`
|
||||
Location string `mapstructure:"location"`
|
||||
Tags map[string]*string `mapstructure:"tags"`
|
||||
Sku *Sku `mapstructure:"sku"`
|
||||
ReplicaCount *int `mapstructure:"replicaCount"`
|
||||
PartitionCount *int `mapstructure:"partitionCount"`
|
||||
Status *string `mapstructure:"status"`
|
||||
StatusDetails *string `mapstructure:"statusDetails"`
|
||||
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>
|
||||
</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/) %>>
|
||||
<a href="#">SQL Resources</a>
|
||||
<ul class="nav nav-visible">
|
||||
|
|
Loading…
Reference in New Issue