diff --git a/azurerm/config.go b/azurerm/config.go index f4414a901a14..5c7ddf5718c5 100644 --- a/azurerm/config.go +++ b/azurerm/config.go @@ -60,7 +60,6 @@ import ( "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage" "github.com/Azure/azure-sdk-for-go/services/trafficmanager/mgmt/2017-05-01/trafficmanager" "github.com/Azure/azure-sdk-for-go/services/web/mgmt/2018-02-01/web" - mainStorage "github.com/Azure/azure-sdk-for-go/storage" "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/adal" @@ -255,7 +254,8 @@ type ArmClient struct { schedulerJobsClient scheduler.JobsClient // Search - searchServicesClient search.ServicesClient + searchServicesClient search.ServicesClient + searchAdminKeysClient search.AdminKeysClient // Security Centre securityCenterPricingClient security.PricingsClient @@ -1030,6 +1030,10 @@ func (c *ArmClient) registerSearchClients(endpoint, subscriptionId string, auth searchClient := search.NewServicesClientWithBaseURI(endpoint, subscriptionId) c.configureClient(&searchClient.Client, auth) c.searchServicesClient = searchClient + + searchAdminKeysClient := search.NewAdminKeysClientWithBaseURI(endpoint, subscriptionId) + c.configureClient(&searchAdminKeysClient.Client, auth) + c.searchAdminKeysClient = searchAdminKeysClient } func (c *ArmClient) registerSecurityCenterClients(endpoint, subscriptionId, ascLocation string, auth autorest.Authorizer) { diff --git a/azurerm/resource_arm_search_service.go b/azurerm/resource_arm_search_service.go index a0cfeca09c91..f126da36aa14 100644 --- a/azurerm/resource_arm_search_service.go +++ b/azurerm/resource_arm_search_service.go @@ -58,6 +58,16 @@ func resourceArmSearchService() *schema.Resource { ForceNew: true, }, + "primary_key": { + Type: schema.TypeString, + Computed: true, + }, + + "secondary_key": { + Type: schema.TypeString, + Computed: true, + }, + "tags": tagsForceNewSchema(), }, } @@ -149,6 +159,13 @@ func resourceArmSearchServiceRead(d *schema.ResourceData, meta interface{}) erro } } + adminKeysClient := meta.(*ArmClient).searchAdminKeysClient + adminKeysResp, err := adminKeysClient.Get(ctx, resourceGroup, name, nil) + if err == nil { + d.Set("primary_key", adminKeysResp.PrimaryKey) + d.Set("secondary_key", adminKeysResp.SecondaryKey) + } + flattenAndSetTags(d, resp.Tags) return nil diff --git a/azurerm/resource_arm_search_service_test.go b/azurerm/resource_arm_search_service_test.go index ae72f3811be6..90ce36881370 100644 --- a/azurerm/resource_arm_search_service_test.go +++ b/azurerm/resource_arm_search_service_test.go @@ -47,6 +47,8 @@ func TestAccAzureRMSearchService_complete(t *testing.T) { testCheckAzureRMSearchServiceExists(resourceName), resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), resource.TestCheckResourceAttr(resourceName, "replica_count", "2"), + resource.TestCheckResourceAttrSet(resourceName, "primary_key"), + resource.TestCheckResourceAttrSet(resourceName, "secondary_key"), ), }, }, diff --git a/website/docs/r/search_service.html.markdown b/website/docs/r/search_service.html.markdown index 220e57b94cef..ae5ec2830f16 100644 --- a/website/docs/r/search_service.html.markdown +++ b/website/docs/r/search_service.html.markdown @@ -54,6 +54,10 @@ The following attributes are exported: * `id` - The Search Service ID. +* `primary_key` - The Search Service Administration primary key. + +* `secondary_key` - The Search Service Administration secondary key. + ## Import Search Services can be imported using the `resource id`, e.g.