Skip to content

Commit 3eab9f2

Browse files
committed
provider/azurerm: Add documentation for the azurerm_search_service
resource
1 parent dbc5464 commit 3eab9f2

7 files changed

Lines changed: 148 additions & 85 deletions

File tree

builtin/providers/azurerm/provider.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ func Provider() terraform.ResourceProvider {
7474
"azurerm_sql_server": resourceArmSqlServer(),
7575
"azurerm_sql_database": resourceArmSqlDatabase(),
7676
"azurerm_sql_firewall_rule": resourceArmSqlFirewallRule(),
77+
"azurerm_search_service": resourceArmSearchService(),
7778
},
7879
ConfigureFunc: providerConfigure,
7980
}
@@ -141,7 +142,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
141142
func registerAzureResourceProvidersWithSubscription(config *Config, client *ArmClient) error {
142143
providerClient := client.providers
143144

144-
providers := []string{"Microsoft.Network", "Microsoft.Compute", "Microsoft.Cdn", "Microsoft.Storage", "Microsoft.Sql"}
145+
providers := []string{"Microsoft.Network", "Microsoft.Compute", "Microsoft.Cdn", "Microsoft.Storage", "Microsoft.Sql", "Microsoft.Search"}
145146

146147
for _, v := range providers {
147148
res, err := providerClient.Register(v)

builtin/providers/azurerm/resource_arm_search_service.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77

88
"github.com/hashicorp/terraform/helper/resource"
99
"github.com/hashicorp/terraform/helper/schema"
10-
"github.com/jen20/riviera/azure"
1110
"github.com/jen20/riviera/search"
1211
)
1312

@@ -78,11 +77,13 @@ func resourceArmSearchServiceCreate(d *schema.ResourceData, meta interface{}) er
7877
}
7978

8079
if v, ok := d.GetOk("replica_count"); ok {
81-
command.ReplicaCount = azure.String(v.(string))
80+
replica_count := v.(int)
81+
command.ReplicaCount = &replica_count
8282
}
8383

8484
if v, ok := d.GetOk("partition_count"); ok {
85-
command.PartitionCount = azure.String(v.(string))
85+
partition_count := v.(int)
86+
command.PartitionCount = &partition_count
8687
}
8788

8889
createRequest := rivieraClient.NewRequest()
@@ -119,7 +120,8 @@ func resourceArmSearchServiceCreate(d *schema.ResourceData, meta interface{}) er
119120
Target: []string{"succeeded"},
120121
Refresh: azureStateRefreshFunc(*resp.ID, client, getSearchServiceCommand),
121122
// ¯\_(ツ)_/¯
122-
Timeout: 30 * time.Minute,
123+
Timeout: 30 * time.Minute,
124+
MinTimeout: 15 * time.Second,
123125
}
124126
if _, err := stateConf.WaitForState(); err != nil {
125127
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
149151

150152
resp := readResponse.Parsed.(*search.GetSearchServiceResponse)
151153
d.Set("sku", resp.Sku)
154+
if resp.PartitionCount != nil {
155+
d.Set("partition_count", resp.PartitionCount)
156+
}
157+
if resp.ReplicaCount != nil {
158+
d.Set("replica_count", resp.ReplicaCount)
159+
}
152160
return nil
153161
}
154162

builtin/providers/azurerm/resource_arm_search_service_test.go

Lines changed: 58 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -23,42 +23,48 @@ func TestAccAzureRMSearchService_basic(t *testing.T) {
2323
Config: config,
2424
Check: resource.ComposeTestCheckFunc(
2525
testCheckAzureRMSearchServiceExists("azurerm_search_service.test"),
26+
resource.TestCheckResourceAttr(
27+
"azurerm_search_service.test", "tags.#", "2"),
2628
),
2729
},
2830
},
2931
})
3032
}
3133

32-
//func TestAccAzureRMSearchService_withTags(t *testing.T) {
33-
// ri := acctest.RandInt()
34-
// preConfig := fmt.Sprintf(testAccAzureRMSearchService_withTags, ri, ri)
35-
// postConfig := fmt.Sprintf(testAccAzureRMSearchService_withTagsUpdated, ri, ri)
36-
//
37-
// resource.Test(t, resource.TestCase{
38-
// PreCheck: func() { testAccPreCheck(t) },
39-
// Providers: testAccProviders,
40-
// CheckDestroy: testCheckAzureRMSearchServiceDestroy,
41-
// Steps: []resource.TestStep{
42-
// resource.TestStep{
43-
// Config: preConfig,
44-
// Check: resource.ComposeTestCheckFunc(
45-
// testCheckAzureRMSearchServiceExists("azurerm_search_service.test"),
46-
// resource.TestCheckResourceAttr(
47-
// "azurerm_search_service.test", "tags.#", "2"),
48-
// ),
49-
// },
50-
//
51-
// resource.TestStep{
52-
// Config: postConfig,
53-
// Check: resource.ComposeTestCheckFunc(
54-
// testCheckAzureRMSearchServiceExists("azurerm_search_service.test"),
55-
// resource.TestCheckResourceAttr(
56-
// "azurerm_search_service.test", "tags.#", "1"),
57-
// ),
58-
// },
59-
// },
60-
// })
61-
//}
34+
func TestAccAzureRMSearchService_updateReplicaCountAndTags(t *testing.T) {
35+
ri := acctest.RandInt()
36+
preConfig := fmt.Sprintf(testAccAzureRMSearchService_basic, ri, ri)
37+
postConfig := fmt.Sprintf(testAccAzureRMSearchService_updated, ri, ri)
38+
39+
resource.Test(t, resource.TestCase{
40+
PreCheck: func() { testAccPreCheck(t) },
41+
Providers: testAccProviders,
42+
CheckDestroy: testCheckAzureRMSearchServiceDestroy,
43+
Steps: []resource.TestStep{
44+
resource.TestStep{
45+
Config: preConfig,
46+
Check: resource.ComposeTestCheckFunc(
47+
testCheckAzureRMSearchServiceExists("azurerm_search_service.test"),
48+
resource.TestCheckResourceAttr(
49+
"azurerm_search_service.test", "tags.#", "2"),
50+
resource.TestCheckResourceAttr(
51+
"azurerm_search_service.test", "replica_count", "1"),
52+
),
53+
},
54+
55+
resource.TestStep{
56+
Config: postConfig,
57+
Check: resource.ComposeTestCheckFunc(
58+
testCheckAzureRMSearchServiceExists("azurerm_search_service.test"),
59+
resource.TestCheckResourceAttr(
60+
"azurerm_search_service.test", "tags.#", "1"),
61+
resource.TestCheckResourceAttr(
62+
"azurerm_search_service.test", "replica_count", "2"),
63+
),
64+
},
65+
},
66+
})
67+
}
6268

6369
func testCheckAzureRMSearchServiceExists(name string) resource.TestCheckFunc {
6470
return func(s *terraform.State) error {
@@ -119,44 +125,28 @@ resource "azurerm_search_service" "test" {
119125
resource_group_name = "${azurerm_resource_group.test.name}"
120126
location = "West US"
121127
sku = "standard"
128+
129+
tags {
130+
environment = "staging"
131+
database = "test"
132+
}
122133
}
123134
`
124135

125-
//var testAccAzureRMSearchService_withTags = `
126-
//resource "azurerm_resource_group" "test" {
127-
// name = "acctest_rg_%d"
128-
// location = "West US"
129-
//}
130-
//resource "azurerm_sql_server" "test" {
131-
// name = "acctestsqlserver%d"
132-
// resource_group_name = "${azurerm_resource_group.test.name}"
133-
// location = "West US"
134-
// version = "12.0"
135-
// administrator_login = "mradministrator"
136-
// administrator_login_password = "thisIsDog11"
137-
//
138-
// tags {
139-
// environment = "staging"
140-
// database = "test"
141-
// }
142-
//}
143-
//`
144-
//
145-
//var testAccAzureRMSearchService_withTagsUpdated = `
146-
//resource "azurerm_resource_group" "test" {
147-
// name = "acctest_rg_%d"
148-
// location = "West US"
149-
//}
150-
//resource "azurerm_sql_server" "test" {
151-
// name = "acctestsqlserver%d"
152-
// resource_group_name = "${azurerm_resource_group.test.name}"
153-
// location = "West US"
154-
// version = "12.0"
155-
// administrator_login = "mradministrator"
156-
// administrator_login_password = "thisIsDog11"
157-
//
158-
// tags {
159-
// environment = "production"
160-
// }
161-
//}
162-
//`
136+
var testAccAzureRMSearchService_updated = `
137+
resource "azurerm_resource_group" "test" {
138+
name = "acctest_rg_%d"
139+
location = "West US"
140+
}
141+
resource "azurerm_search_service" "test" {
142+
name = "acctestsearchservice%d"
143+
resource_group_name = "${azurerm_resource_group.test.name}"
144+
location = "West US"
145+
sku = "standard"
146+
replica_count = 2
147+
148+
tags {
149+
environment = "production"
150+
}
151+
}
152+
`

vendor/github.com/jen20/riviera/search/create_or_update_search_service.go

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/jen20/riviera/search/get_search_service.go

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
layout: "azurerm"
3+
page_title: "Azure Resource Manager: azurerm_search_service"
4+
sidebar_current: "docs-azurerm-resource-search-service"
5+
description: |-
6+
Manage a Search Service.
7+
---
8+
9+
# azurerm\_search\_service
10+
11+
Allows you to manage an Azure Search Service
12+
13+
## Example Usage
14+
15+
```
16+
resource "azurerm_resource_group" "test" {
17+
name = "acceptanceTestResourceGroup1"
18+
location = "West US"
19+
}
20+
resource "azurerm_search_service" "test" {
21+
name = "acceptanceTestSearchService1"
22+
resource_group_name = "${azurerm_resource_group.test.name}"
23+
location = "West US"
24+
sku = "standard"
25+
26+
tags {
27+
environment = "staging"
28+
database = "test"
29+
}
30+
}
31+
```
32+
## Argument Reference
33+
34+
The following arguments are supported:
35+
36+
* `name` - (Required) The name of the Search Service.
37+
38+
* `resource_group_name` - (Required) The name of the resource group in which to
39+
create the Search Service.
40+
41+
* `location` - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.
42+
43+
* `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
44+
45+
* `replica_count` - (Optional) Default is 1. Valid values include 1 through 12. Valid only when `sku` is `standard`.
46+
47+
* `partition_count` - (Optional) Default is 1. Valid values include 1, 2, 3, 4, 6, or 12. Valid only when `sku` is `standard`.
48+
49+
* `tags` - (Optional) A mapping of tags to assign to the resource.
50+
51+
## Attributes Reference
52+
53+
The following attributes are exported:
54+
55+
* `id` - The Search Service ID.

website/source/layouts/azurerm.erb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@
112112
</ul>
113113
</li>
114114

115+
<li<%= sidebar_current(/^docs-azurerm-resource-search/) %>>
116+
<a href="#">Search Resources</a>
117+
<ul class="nav nav-visible">
118+
<li<%= sidebar_current("docs-azurerm-resource-search-service") %>>
119+
<a href="/docs/providers/azurerm/r/search_service.html">azurerm_search_service</a>
120+
</li>
121+
</ul>
122+
</li>
123+
115124
<li<%= sidebar_current(/^docs-azurerm-resource-sql/) %>>
116125
<a href="#">SQL Resources</a>
117126
<ul class="nav nav-visible">

0 commit comments

Comments
 (0)