How ukhan262/terraform-azurerm-search-service works
1. This repository is a Terraform module, not an application. Its purpose is to provision and configure an Azure Search Service stack with optional private connectivity and shared private link associations.
2. The module boundary is the Terraform root itself: main.tf, variables.tf, outputs.tf, and versions.tf. There are no nested modules, so all infrastructure composition happens directly in this module.
3. The core managed service is Azure Cognitive Search / Azure Search Service, created through azurerm_search_service resources. The module exposes the standard service sizing and deployment knobs: sku, replica_count, partition_count, location, resource_group_name, and disable_local_auth.
4. A second provisioning path uses azapi_resource and azapi_update_resource, which indicates the module reaches into Azure ARM APIs for features that are either newer, less common, or not fully modeled in azurerm. This is typically the boundary where service-specific configuration is applied after the base resource exists.
5. Network isolation is a first-class concern. The module creates an azurerm_private_endpoint tied to a supplied subnet_id, and it optionally integrates with a private_dns_zone_id. That means consumers can place the search service behind private IP connectivity instead of public access.
6. The module also manages azurerm_search_shared_private_link_service resources from an input list called spls. This is the outbound/private-link side of the architecture, letting the search service connect privately to other Azure resources or accept approved private link relationships.
7. There is an azapi_resource_list data source in the design, which suggests the module discovers existing Azure resources and uses that discovery to drive approval or mapping logic. In other words, the module is not only declarative creation; it also reads Azure state to connect resources correctly.
8. Inputs define the module’s contract. Required inputs cover the service identity, capacity, and connectivity: name, location, resource_group_name, sku, replica_count, partition_count, subnet_id, srch_info_deploy_mode, and spls. Optional inputs such as tags, resource_group_id, private_dns_zone_id, and disable_local_auth allow environment-specific tuning.
9. Outputs are intentionally minimal. The single documented output, mapped_resources, implies the module returns a normalized view of created or discovered Azure resources rather than exposing every internal resource directly. That makes the module easier to consume as an infrastructure building block.
10. The runtime and provider boundary is Azure Terraform: azurerm handles the mainstream resource types, while azapi bridges gaps to Azure’s ARM surface. This combination is the main architectural clue that the module must support both stable infrastructure creation and lower-level Azure service operations.
11. Repository automation is limited to documentation generation. The GitHub Actions workflow generate-docs.yml and .terraform-docs.yml indicate the README is generated from Terraform metadata, keeping inputs, outputs, providers, and resources in sync with code.
12. For an architecture diagram, the important flow is: consumer variables enter the Terraform module; the module provisions the Search Service; it then wires private endpoint and shared private link dependencies; finally it emits a compact output map for downstream stacks. The main external boundary is Azure, with networking and ARM API access as the two key integration points.
Main entry points: main.tf Compose · generate-docs.yml Docs workflow · versions.tf azurerm · variables.tf Inputs
Components 15
Terraform module
Root module boundary and public interface
- Consumer · Terraform caller supplying inputs
- Inputs · Module contract for service, capacity, and connectivity
variables.tf - Compose · Top-level Terraform composition for the search service stack
main.tf - Outputs · Normalized values returned to downstream stacks
outputs.tf - Versions · Provider and Terraform version constraints
versions.tf
Azure stack
Managed service, networking, and ARM integrations
- Search · Core Azure Cognitive Search service
main.tf - ARM tweaks · Post-create configuration via Azure ARM APIs
main.tf - Discover · Reads existing Azure resources to drive mapping logic
main.tf - Private endpoint · Private IP connectivity for the search service
main.tf - Private DNS · Optional private DNS zone integration
main.tf - Shared links · Outbound shared private link associations
main.tf - azurerm · Main Terraform provider for Azure resources
versions.tf - azapi · ARM API bridge for newer or less modeled features
versions.tf
Docs automation
Repository automation for generated documentation
- Docs workflow · Generates README content from Terraform metadata
.github/workflows/generate-docs.yml - Docs config · Documentation generation settings
.terraform-docs.yml
Connections 20
- Consumer → Inputs: sets · Caller provides module inputs
- Inputs → Compose: drives · Inputs control the root composition
- Compose → Search: creates · Provision the Azure Search service
- Compose → ARM tweaks: configures · Apply service-specific ARM settings
- Compose → Discover: reads · Discover Azure state for mapping and approval logic
- Compose → Private endpoint: creates · Attach private connectivity
- Private endpoint → Private DNS: binds · Optionally use private DNS
- Compose → Shared links: creates · Manage shared private link associations
- Search → Outputs: feeds · Created resource contributes to output map
- Discover → Outputs: feeds · Discovered resources are normalized for consumers
- azurerm → Search: provides · Primary provider for managed service
- azurerm → Private endpoint: provides · Primary provider for private endpoint
- azurerm → Shared links: provides · Primary provider for shared private links
- azapi → ARM tweaks: provides · ARM bridge provider for advanced configuration
- Versions → azurerm: pins · Constrains provider version
- Versions → azapi: pins · Constrains provider version
- Docs config → Docs workflow: configures · Documentation generation settings used by workflow
- Docs workflow → Inputs: renders · Publishes input metadata to README
- Docs workflow → Outputs: renders · Publishes output metadata to README
- Docs workflow → Versions: renders · Publishes provider/version metadata to README