hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
42.68k stars 9.55k forks source link

azurerm_template_deployment errors when using Service Fabric ARM template #13674

Closed HighwayofLife closed 7 years ago

HighwayofLife commented 7 years ago

Attempting to generate a simple Azure Service Fabric infrastructure in Terraform by using azurerm_template_deployment to load an ARM (Azure Resource Manager) template containing the Service Fabric infrastructure causes an error after about 20 minutes.

1 error(s) occurred:
* azurerm_template_deployment.sfcluster: 1 error(s) occurred:
* azurerm_template_deployment.sfcluster: unexpected EOF

panic: interface conversion: interface {} is map[string]interface {}, not string

However the deployment in Azure Portal shows as successful deployment and all resources are created.

Terraform Version

Terraform version: 0.9.2 6365269541c8e3150ebe638a5c555e1424071417+CHANGES

Affected Resource

Debug Output

panic: interface conversion: interface {} is map[string]interface {}, not string
2017/04/14 20:00:25 [DEBUG] plugin: terraform: 
2017/04/14 20:00:25 [DEBUG] plugin: terraform: goroutine 114 [running]:
2017/04/14 20:00:25 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/builtin/providers/azurerm.resourceArmTemplateDeploymentRead(0xc420212850, 0x46b5480, 0xc42090e000, 0x0, 0x0)
2017/04/14 20:00:25 [DEBUG] plugin: terraform:  /opt/gopath/src/github.com/hashicorp/terraform/builtin/providers/azurerm/resource_arm_template_deployment.go:165 +0x457
2017/04/14 20:00:25 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/builtin/providers/azurerm.resourceArmTemplateDeploymentCreate(0xc420212850, 0x46b5480, 0xc42090e000, 0x0, 0x0)
2017/04/14 20:00:25 [DEBUG] plugin: terraform:  /opt/gopath/src/github.com/hashicorp/terraform/builtin/providers/azurerm/resource_arm_template_deployment.go:128 +0xa5e
2017/04/14 20:00:25 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/helper/schema.(*Resource).Apply(0xc420d778c0, 0xc42077ac80, 0xc4208d35c0, 0x46b5480, 0xc42090e000, 0x1, 0x28, 0xc420315ef0)
2017/04/14 20:00:25 [DEBUG] plugin: terraform:  /opt/gopath/src/github.com/hashicorp/terraform/helper/schema/resource.go:186 +0x48d
2017/04/14 20:00:25 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/helper/schema.(*Provider).Apply(0xc420213420, 0xc42077ac30, 0xc42077ac80, 0xc4208d35c0, 0x7f60ed90b000, 0x0, 0x0)
2017/04/14 20:00:25 [DEBUG] plugin: terraform:  /opt/gopath/src/github.com/hashicorp/terraform/helper/schema/provider.go:242 +0x9b
2017/04/14 20:00:25 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/plugin.(*ResourceProviderServer).Apply(0xc42088e420, 0xc4208d2bc0, 0xc4208a93c0, 0x0, 0x0)
2017/04/14 20:00:25 [DEBUG] plugin: terraform:  /opt/gopath/src/github.com/hashicorp/terraform/plugin/resource_provider.go:488 +0x57
2017/04/14 20:00:25 [DEBUG] plugin: terraform: reflect.Value.call(0xc42025ec60, 0xc42096b8d8, 0x13, 0x4cac114, 0x4, 0xc4208ebf20, 0x3, 0x3, 0x0, 0xc4206216f8, ...)
2017/04/14 20:00:25 [DEBUG] plugin: terraform:  /opt/go/src/reflect/value.go:434 +0x91f
2017/04/14 20:00:25 [DEBUG] plugin: terraform: reflect.Value.Call(0xc42025ec60, 0xc42096b8d8, 0x13, 0xc420621720, 0x3, 0x3, 0xc4206217c0, 0x79173e, 0xc4209121e0)
2017/04/14 20:00:25 [DEBUG] plugin: terraform:  /opt/go/src/reflect/value.go:302 +0xa4
2017/04/14 20:00:25 [DEBUG] plugin: terraform: net/rpc.(*service).call(0xc420875780, 0xc420875740, 0xc4204dfbd8, 0xc42035ec00, 0xc42088f400, 0x3f2f5e0, 0xc4208d2bc0, 0x16, 0x3f2f620, 0xc4208a93c0, ...)
2017/04/14 20:00:25 [DEBUG] plugin: terraform:  /opt/go/src/net/rpc/server.go:387 +0x144
2017/04/14 20:00:25 [DEBUG] plugin: terraform: created by net/rpc.(*Server).ServeCodec
2017/04/14 20:00:25 [DEBUG] plugin: terraform:  /opt/go/src/net/rpc/server.go:481 +0x404
2017/04/14 20:00:25 [DEBUG] root: eval: *terraform.EvalWriteState
2017/04/14 20:00:25 [DEBUG] root: eval: *terraform.EvalApplyProvisioners
2017/04/14 20:00:25 [DEBUG] root: eval: *terraform.EvalIf
2017/04/14 20:00:25 [DEBUG] root: eval: *terraform.EvalWriteState
2017/04/14 20:00:25 [DEBUG] root: eval: *terraform.EvalWriteDiff
2017/04/14 20:00:25 [DEBUG] root: eval: *terraform.EvalApplyPost
2017/04/14 20:00:25 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* azurerm_template_deployment.sfcluster: unexpected EOF
2017/04/14 20:00:25 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* azurerm_template_deployment.sfcluster: unexpected EOF
2017/04/14 20:00:25 [TRACE] [walkApply] Exiting eval tree: azurerm_template_deployment.sfcluster
2017/04/14 20:00:25 [DEBUG] dag/walk: upstream errored, not walking "meta.count-boundary (count boundary fixup)"
2017/04/14 20:00:25 [TRACE] Preserving existing state lineage "38213277-3a7a-4467-b2fc-a695e525b1f4"
2017/04/14 20:00:25 [DEBUG] plugin: /opt/terraform/terraform: plugin process exited
2017/04/14 20:00:25 [TRACE] Preserving existing state lineage "38213277-3a7a-4467-b2fc-a695e525b1f4"
2017/04/14 20:00:25 [DEBUG] plugin: waiting for all plugin processes to complete...
2017/04/14 20:00:25 [WARN] plugin: error closing client during Kill: connection is shut down

Crash Log

https://gist.github.com/HighwayofLife/964dedbfb4561cabd718d379c24c990a

Expected Behavior

Deployment to Azure succeeded, Terraform would report success.

Actual Behavior

Terraform reported a long running process and closed unexpectedly with the error: azurerm_template_deployment.sfcluster: unexpected EOF

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. Create Service Fabric Cluster in Azure to generate automation script (ARM Template)
  2. Include the ARM template in the Terraform template.
  3. Call terraform apply
  4. Creating a simple SF cluster with 5 nodes takes about 20-25 minutes. At the 20 minute mark, Terraform would fail.

Use the template created through Azure and include in main.tf file:

variable "resourceGroupName" {}
variable "resourceName" {}
variable "resourceTag" {}
variable "clusterName" {}
variable "clusterLocation" {}
variable "computeLocation" {}
variable "adminUserName" {}
variable "adminPassword" {}
variable "nicName" {}
variable "publicIPAddressName" {}
variable "vmStorageAccountName" {}
variable "dnsName" {}
variable "virtualNetworkName" {}
variable "lbName" {}
variable "lbIPName" {}
variable "applicationDiagnosticsStorageAccountName" {}
variable "supportLogStorageAccountName" {}
variable "vmImageSku" {}

# Create a resource group
resource "azurerm_resource_group" "sfcluster" {
  name     = "${var.resourceGroupName}"
  location = "${var.clusterLocation}"

    tags {
    environment = "${var.resourceTag}"
  }
}

resource "azurerm_template_deployment" "sfcluster" {
  name                = "${var.clusterName}"
  resource_group_name = "${var.resourceGroupName}"
  deployment_mode     = "Incremental"
  template_body       = "${file("./sf_template.json")}"

  parameters {
    clusterName           = "${var.clusterName}"
    clusterLocation       = "${var.clusterLocation}"
    computeLocation       = "${var.computeLocation}"
    adminUserName         = "${var.adminUserName}"
    adminPassword         = "${var.adminPassword}"
    nicName               = "${var.nicName}"
    publicIPAddressName   = "${var.publicIPAddressName}"
    vmStorageAccountName  = "${var.vmStorageAccountName}"
    dnsName               = "${var.dnsName}"
    virtualNetworkName    = "${var.virtualNetworkName}"
    lbName                = "${var.lbName}"
    lbIPName              = "${var.lbIPName}"
    vmImageSku               = "${var.vmImageSku}"
    applicationDiagnosticsStorageAccountName  = "${var.applicationDiagnosticsStorageAccountName}"
    supportLogStorageAccountName              = "${var.supportLogStorageAccountName}"
  }
}

Important Factoids

Service Fabric is an unsupported native Terraform resource, which is why using the ARM template is necessary.

HighwayofLife commented 7 years ago

Further data, relevant code is from: https://github.com/hashicorp/terraform/blob/master/builtin/providers/azurerm/resource_arm_template_deployment.go func resourceArmTemplateDeploymentRead line 154:

    var outputs map[string]string
    if resp.Properties.Outputs != nil && len(*resp.Properties.Outputs) > 0 {
        outputs = make(map[string]string)
        for key, output := range *resp.Properties.Outputs {
            outputMap := output.(map[string]interface{})
            outputValue, ok := outputMap["value"]
            if !ok {
                // No value
                continue
            }

            outputs[key] = outputValue.(string)
        }
    }

    d.Set("outputs", outputs)

The ARM (JSON) template contains outputs in the following format:

    "outputs": {
        "clusterProperties": {
            "value": "[reference(parameters('clusterName'))]",
            "type": "object"
        }
    }
HighwayofLife commented 7 years ago

Pull request: #13670 addresses this issue, I believe.

ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.