The query_keys is a list of objects.
Example code
provider "azurerm" {
version = "~>2.19.0"
features {}
}
resource "azurerm_resource_group" "example" {
name = "example-resources"
location = "East US"
}
resource "azurerm_search_service" "example" {
name = "example-search-service"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
sku = "standard"
}
output "query_keys_key" {
value = azurerm_search_service.example.query_keys[0].key
}
output "query_keys_name" {
value = azurerm_search_service.example.query_keys[0].name
}
Example output
> terraform apply
azurerm_resource_group.example: Refreshing state... [id=/subscriptions/redacted/resourceGroups/example-resources]
azurerm_search_service.example: Refreshing state... [id=/subscriptions/redacted/resourceGroups/example-resources/providers/Microsoft.Search/searchServices/example-search-service]
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
Outputs:
query_keys_key = 662EEE1DD452E082922C1AF00B0BBFA9
query_keys_name =
Run a terraform show
to see
> terraform show
# azurerm_resource_group.example:
resource "azurerm_resource_group" "example" {
id = "/subscriptions/redacted/resourceGroups/example-resources"
location = "eastus"
name = "example-resources"
}
# azurerm_search_service.example:
resource "azurerm_search_service" "example" {
id = "/subscriptions/redacted/resourceGroups/example-resources/providers/Microsoft.Search/searchServices/example-search-service"
location = "eastus"
name = "example-search-service"
partition_count = 1
primary_key = "3EE7E9F80715E0451EEBC25196808563"
query_keys = [
{
key = "662EEE1DD452E08292BC1AF01B0BBFA9"
name = ""
},
]
replica_count = 1
resource_group_name = "example-resources"
secondary_key = "11CCA067EEC7E04FC1F39582FD01C316"
sku = "standard"
}