5
votes

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
Nope. With that documentation I can create the resource to manage service fabric, but not the cluster itself. So it's just stuck waiting for nodes to join. - Tvo
Ah, ok. I wonder if that link paired with this link docs.microsoft.com/en-us/azure/terraform/… could get you where you need to be. I'll give it a shot myself. - Steve L.
Do you have a list of what resources need to be created, or even better, a complete terraform example? I initially created a cluster through the portal, which hides a lot of the internals. - user247702
I started a terraform script to setup the resources. I think the certificate management part is not working. github.com/TrevorVonSeggern/ServiceFabric_Terraform - Tvo

1 Answers

1
votes

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
    })
  }