Create a Service Fabric cluster with Terraform

Viewed 1996

I'm trying to create a Service Fabric cluster in Azure with a Terraform script. The Azure service provider in Terraform has released a "Service Fabric Cluster" (azurerm_service_fabric_cluster) resource. That resource only creates the service fabric management part, ie not the vm scale sets, or networking resources.

How do I create a working SF cluster via Terraform?

1 Answers

Terraform azurerm_service_fabric_cluster resource only provisions the Management. To provision the nodes, Deploy the VMSS with service fabric extension which configures the SF Nodes.

Refer the example on the official provider GitHub for information.

https://github.com/terraform-providers/terraform-provider-azurerm/tree/master/examples/service-fabric/windows-vmss-self-signed-certs

extension {
    name                       = "${var.prefix}ServiceFabricNode"
    publisher                  = "Microsoft.Azure.ServiceFabric"
    type                       = "ServiceFabricNode"
    type_handler_version       = "1.1"
    auto_upgrade_minor_version = false

    settings = jsonencode({
      "clusterEndpoint"    = azurerm_service_fabric_cluster.example.cluster_endpoint
      "nodeTypeRef"        = azurerm_service_fabric_cluster.example.node_type[0].name
      "durabilityLevel"    = "bronze"
      "nicPrefixOverride"  = azurerm_subnet.example.address_prefixes[0]
      "enableParallelJobs" = true
      "certificate" = {
        "commonNames" = [
          "${var.prefix}servicefabric.${var.location}.cloudapp.azure.com",
        ]
        "x509StoreName" = "My"
      }
    })

    protected_settings = jsonencode({
      "StorageAccountKey1" = azurerm_storage_account.example.primary_access_key
      "StorageAccountKey2" = azurerm_storage_account.example.secondary_access_key
    })
  }
Related