Terraform: Terraform crash on plan

Created on 13 Mar 2019  路  2Comments  路  Source: hashicorp/terraform

Terraform Version

Terraform v0.11.11
+ provider.aws v1.60.0
+ provider.github v1.3.0
+ provider.random v2.0.0

Terraform Configuration Files

module "webhook_secret" {
  source        = "../secretsmanager"
  name          = "${var.environment}/${var.github_repository}/codepipeline"
  auto_generate = true
}

secretsmanager module

resource "aws_secretsmanager_secret" "default" {
  name = "${var.name}"
}

resource "aws_secretsmanager_secret_version" "default" {
  secret_id     = "${aws_secretsmanager_secret.default.id}"
  secret_string = "${var.auto_generate == true ? random_string.default.result : var.secret_string}"
}

resource "random_string" "default" {
  length           = "${var.length}"
  upper            = "${var.upper}"
  min_upper        = "${var.min_upper}"
  lower            = "${var.lower}"
  min_lower        = "${var.min_lower}"
  number           = "${var.number}"
  min_numeric      = "${var.min_numeric}"
  special          = "${var.special}"
  min_special      = "${var.min_special}"
  override_special = "${var.override_special}"
}

Debug Output

2019/03/12 17:38:01 [DEBUG] [aws-sdk-go] <?xml version="1.0" encoding="UTF-8"?>
<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Name>XXXXX</Name><Prefix>env:/</Prefix><Marker></Marker><MaxKeys>1000</MaxKeys><IsTruncated>false</IsTruncated></ListBucketResult>
2019/03/12 17:38:01 [DEBUG] [aws-sdk-go] DEBUG: Request s3/GetObject Details:
---[ REQUEST POST-SIGN ]-----------------------------
GET /XXXXX/XXXXX HTTP/1.1
Host: XXXXX.s3.amazonaws.com
User-Agent: aws-sdk-go/1.14.31 (go1.11.1; darwin; amd64) APN/1.0 HashiCorp/1.0 Terraform/0.11.11
Authorization: AWS4-HMAC-SHA256 Credential=XXXXX/20190312/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date;x-amz-security-token, Signature=XXXXX
X-Amz-Content-Sha256: XXXXX
X-Amz-Date: 20190312T233801Z
X-Amz-Security-Token:XXXXX
Accept-Encoding: gzip


-----------------------------------------------------
2019/03/12 17:38:02 [DEBUG] [aws-sdk-go] DEBUG: Response s3/GetObject Details:
---[ RESPONSE ]--------------------------------------
HTTP/1.1 200 OK
Connection: close
Content-Length: 295403
Accept-Ranges: bytes
Content-Type: application/json
Date: Tue, 12 Mar 2019 23:38:03 GMT
Etag: "797707dce5fd2027b8f4d7708b825cab"
Last-Modified: Tue, 12 Mar 2019 20:42:31 GMT
Server: AmazonS3
X-Amz-Id-2: XXXXX
X-Amz-Request-Id: XXXXX
X-Amz-Version-Id: XXXXX


-----------------------------------------------------
2019/03/12 17:38:02 [DEBUG] [aws-sdk-go]
2019/03/12 17:38:02 [TRACE] Preserving existing state lineage "bd5d3edb-a858-7cea-043c-2905ece42f79"
2019/03/12 17:38:02 [TRACE] Preserving existing state lineage "bd5d3edb-a858-7cea-043c-2905ece42f79"

Crash Output

panic: Unknown: %!s(float64=5)

goroutine 10228 [running]:
github.com/hashicorp/terraform/builtin/providers/terraform.flatten(0xc000921c50, 0xc00084e2d8, 0x7, 0x343dde0, 0xc000514e40, 0x94)
        /opt/gopath/src/github.com/hashicorp/terraform/builtin/providers/terraform/flatten.go:48 +0x48d
github.com/hashicorp/terraform/builtin/providers/terraform.flattenMap(0xc000921c50, 0xc00083a1a0, 0x5, 0x3449420, 0xc00092f710, 0x15)
        /opt/gopath/src/github.com/hashicorp/terraform/builtin/providers/terraform/flatten.go:65 +0x440
github.com/hashicorp/terraform/builtin/providers/terraform.flatten(0xc000921c50, 0xc00083a1a0, 0x5, 0x3449420, 0xc00092f710, 0x15)
        /opt/gopath/src/github.com/hashicorp/terraform/builtin/providers/terraform/flatten.go:42 +0x38b
github.com/hashicorp/terraform/builtin/providers/terraform.remoteStateFlatten(0xc000e69468, 0xc000e69468)
        /opt/gopath/src/github.com/hashicorp/terraform/builtin/providers/terraform/flatten.go:21 +0xb4
github.com/hashicorp/terraform/builtin/providers/terraform.dataSourceRemoteStateRead(0xc00103fe30, 0x0, 0x0, 0xc00103fe30, 0x0)
        /opt/gopath/src/github.com/hashicorp/terraform/builtin/providers/terraform/data_source_state.go:520 +0xa3e
github.com/hashicorp/terraform/helper/schema.(*Resource).ReadDataApply(0xc00106a310, 0xc0008d75a0, 0x0, 0x0, 0xc00090eb18, 0xc000768d01, 0xc0004d73b0)
        /opt/gopath/src/github.com/hashicorp/terraform/helper/schema/resource.go:290 +0x88
github.com/hashicorp/terraform/helper/schema.(*Provider).ReadDataApply(0xc00106a380, 0xc000c9aaf0, 0xc0008d75a0, 0x0, 0x30, 0xc000af4000)
        /opt/gopath/src/github.com/hashicorp/terraform/helper/schema/provider.go:426 +0x92
github.com/hashicorp/terraform/terraform.(*EvalReadDataApply).Eval(0xc000e86e40, 0x3ea2ec0, 0xc000315790, 0x2, 0x2, 0x3bdc1a0, 0x4)
        /opt/gopath/src/github.com/hashicorp/terraform/terraform/eval_read_data.go:122 +0xf9
github.com/hashicorp/terraform/terraform.EvalRaw(0x3e7c700, 0xc000e86e40, 0x3ea2ec0, 0xc000315790, 0x0, 0x0, 0x0, 0x0)
        /opt/gopath/src/github.com/hashicorp/terraform/terraform/eval.go:53 +0x156
github.com/hashicorp/terraform/terraform.(*EvalSequence).Eval(0xc000e86e60, 0x3ea2ec0, 0xc000315790, 0x2, 0x2, 0x3bdc1a0, 0x4)
        /opt/gopath/src/github.com/hashicorp/terraform/terraform/eval_sequence.go:14 +0x9c
github.com/hashicorp/terraform/terraform.EvalRaw(0x3e7c800, 0xc000e86e60, 0x3ea2ec0, 0xc000315790, 0x343be00, 0x643f005, 0x315ad00, 0xc000537b70)
        /opt/gopath/src/github.com/hashicorp/terraform/terraform/eval.go:53 +0x156
github.com/hashicorp/terraform/terraform.Eval(0x3e7c800, 0xc000e86e60, 0x3ea2ec0, 0xc000315790, 0xc000e86e60, 0x3e7c800, 0xc000e86e60, 0x103c22b)
        /opt/gopath/src/github.com/hashicorp/terraform/terraform/eval.go:34 +0x4d
github.com/hashicorp/terraform/terraform.(*Graph).walk.func1(0x3aa9c20, 0xc00047a8b8, 0x0, 0x0)
        /opt/gopath/src/github.com/hashicorp/terraform/terraform/graph.go:126 +0xc45
github.com/hashicorp/terraform/dag.(*Walker).walkVertex(0xc001423490, 0x3aa9c20, 0xc00047a8b8, 0xc000513e80)
        /opt/gopath/src/github.com/hashicorp/terraform/dag/walk.go:387 +0x367
created by github.com/hashicorp/terraform/dag.(*Walker).Update
        /opt/gopath/src/github.com/hashicorp/terraform/dag/walk.go:310 +0x986
panic: Unknown: %!!(MISSING)s(float64=5)

goroutine 10228 [running]:
github.com/hashicorp/terraform/builtin/providers/terraform.flatten(0xc000921c50, 0xc00084e2d8, 0x7, 0x343dde0, 0xc000514e40, 0x94)
        /opt/gopath/src/github.com/hashicorp/terraform/builtin/providers/terraform/flatten.go:48 +0x48d
github.com/hashicorp/terraform/builtin/providers/terraform.flattenMap(0xc000921c50, 0xc00083a1a0, 0x5, 0x3449420, 0xc00092f710, 0x15)
        /opt/gopath/src/github.com/hashicorp/terraform/builtin/providers/terraform/flatten.go:65 +0x440
github.com/hashicorp/terraform/builtin/providers/terraform.flatten(0xc000921c50, 0xc00083a1a0, 0x5, 0x3449420, 0xc00092f710, 0x15)
        /opt/gopath/src/github.com/hashicorp/terraform/builtin/providers/terraform/flatten.go:42 +0x38b
github.com/hashicorp/terraform/builtin/providers/terraform.remoteStateFlatten(0xc000e69468, 0xc000e69468)
        /opt/gopath/src/github.com/hashicorp/terraform/builtin/providers/terraform/flatten.go:21 +0xb4
github.com/hashicorp/terraform/builtin/providers/terraform.dataSourceRemoteStateRead(0xc00103fe30, 0x0, 0x0, 0xc00103fe30, 0x0)
        /opt/gopath/src/github.com/hashicorp/terraform/builtin/providers/terraform/data_source_state.go:520 +0xa3e
github.com/hashicorp/terraform/helper/schema.(*Resource).ReadDataApply(0xc00106a310, 0xc0008d75a0, 0x0, 0x0, 0xc00090eb18, 0xc000768d01, 0xc0004d73b0)
        /opt/gopath/src/github.com/hashicorp/terraform/helper/schema/resource.go:290 +0x88
github.com/hashicorp/terraform/helper/schema.(*Provider).ReadDataApply(0xc00106a380, 0xc000c9aaf0, 0xc0008d75a0, 0x0, 0x30, 0xc000af4000)
        /opt/gopath/src/github.com/hashicorp/terraform/helper/schema/provider.go:426 +0x92
github.com/hashicorp/terraform/terraform.(*EvalReadDataApply).Eval(0xc000e86e40, 0x3ea2ec0, 0xc000315790, 0x2, 0x2, 0x3bdc1a0, 0x4)
        /opt/gopath/src/github.com/hashicorp/terraform/terraform/eval_read_data.go:122 +0xf9
github.com/hashicorp/terraform/terraform.EvalRaw(0x3e7c700, 0xc000e86e40, 0x3ea2ec0, 0xc000315790, 0x0, 0x0, 0x0, 0x0)
        /opt/gopath/src/github.com/hashicorp/terraform/terraform/eval.go:53 +0x156
github.com/hashicorp/terraform/terraform.(*EvalSequence).Eval(0xc000e86e60, 0x3ea2ec0, 0xc000315790, 0x2, 0x2, 0x3bdc1a0, 0x4)
        /opt/gopath/src/github.com/hashicorp/terraform/terraform/eval_sequence.go:14 +0x9c
github.com/hashicorp/terraform/terraform.EvalRaw(0x3e7c800, 0xc000e86e60, 0x3ea2ec0, 0xc000315790, 0x343be00, 0x643f005, 0x315ad00, 0xc000537b70)
        /opt/gopath/src/github.com/hashicorp/terraform/terraform/eval.go:53 +0x156
github.com/hashicorp/terraform/terraform.Eval(0x3e7c800, 0xc000e86e60, 0x3ea2ec0, 0xc000315790, 0xc000e86e60, 0x3e7c800, 0xc000e86e60, 0x103c22b)
        /opt/gopath/src/github.com/hashicorp/terraform/terraform/eval.go:34 +0x4d
github.com/hashicorp/terraform/terraform.(*Graph).walk.func1(0x3aa9c20, 0xc00047a8b8, 0x0, 0x0)
        /opt/gopath/src/github.com/hashicorp/terraform/terraform/graph.go:126 +0xc45
github.com/hashicorp/terraform/dag.(*Walker).walkVertex(0xc001423490, 0x3aa9c20, 0xc00047a8b8, 0xc000513e80)
        /opt/gopath/src/github.com/hashicorp/terraform/dag/walk.go:387 +0x367
created by github.com/hashicorp/terraform/dag.(*Walker).Update
        /opt/gopath/src/github.com/hashicorp/terraform/dag/walk.go:310 +0x986

Expected Behavior

Creates the plan.

Actual Behavior

Terraform crashes

Steps to Reproduce

  1. terraform init
  2. terraform plan

Additional Context

It suddenly stop working.

References

bug crash hashiboignore provideterraform

Most helpful comment

Hi @luisc09! Sorry for this crash and thanks for reporting it.

The panic trace suggests that the problem is coming from a terraform_remote_state data resource. You didn't show one in your example, but perhaps there's one elsewhere in your configuration whose source code you could share?

I've not seen this problem before but it looks like there is a floating point number in one of your outputs, which the data source isn't expecting to find: output values are supposed to always be either strings, lists of strings, or maps of strings in Terraform 0.11.

The remote state data source works completely differently in master now since it was rewritten to support the new state format coming in Terraform v0.12, and so the codepath where this is crashing is no longer present. To work around it in the mean time, perhaps if you have an output in the configuration that is producing this state which is set to a numeric value you could force it to be converted to a string as expected using something like "${format("%d", your_number)}" (using %d here because the 5 in the error messages is an integer; if decimal values are allowed too, use %f instead.)

All 2 comments

Hi @luisc09! Sorry for this crash and thanks for reporting it.

The panic trace suggests that the problem is coming from a terraform_remote_state data resource. You didn't show one in your example, but perhaps there's one elsewhere in your configuration whose source code you could share?

I've not seen this problem before but it looks like there is a floating point number in one of your outputs, which the data source isn't expecting to find: output values are supposed to always be either strings, lists of strings, or maps of strings in Terraform 0.11.

The remote state data source works completely differently in master now since it was rewritten to support the new state format coming in Terraform v0.12, and so the codepath where this is crashing is no longer present. To work around it in the mean time, perhaps if you have an output in the configuration that is producing this state which is set to a numeric value you could force it to be converted to a string as expected using something like "${format("%d", your_number)}" (using %d here because the 5 in the error messages is an integer; if decimal values are allowed too, use %f instead.)

Oh my! Thanks @apparentlymart!

As you mentioned the issue was on the terraform_remote_state, I was doing some tests with the outputs and I had set the following:

output "map_test" {
    "%" = 5
    prop = "yes"
}

I removed it and it started to work again!

I will close this, and thanks for all the help!

Was this page helpful?
0 / 5 - 0 ratings