Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform crashed when terraform plan #21835

Closed
relifeted opened this issue Jun 21, 2019 · 4 comments
Closed

Terraform crashed when terraform plan #21835

relifeted opened this issue Jun 21, 2019 · 4 comments

Comments

@relifeted
Copy link

Terraform Version

Terraform v0.12.2

Terraform Configuration Files

locals {
  aws_cloudwatch_event_target_codebuild_input_template = <<TEMPLATE
{
  "Service": "CodeBuild",
  "project": "$project-name#",
  "status": "$build-status#",
  "region": "$region#"
}
TEMPLATE

}

resource "aws_cloudwatch_event_rule" "CodeBuild_Build_State" {
  name = "capture-CodeBuild-Build-State-events"
  description = "Capture all CodeBuild Build State events"

  event_pattern = <<PATTERN
{
  "source": [ 
    "aws.codebuild"
  ], 
  "detail-type": [
    "CodeBuild Build State Change"
  ],
  "detail": {
    "build-status": [
      "IN_PROGRESS",
      "SUCCEEDED", 
      "FAILED",
      "STOPPED" 
    ]
  }  
}
PATTERN

}

resource "aws_cloudwatch_event_target" "CodeBuild_Build_State" {
  target_id = "sns"
  rule      = aws_cloudwatch_event_rule.CodeBuild_Build_State.name
  arn       = aws_sns_topic.deployments.arn

  input_transformer {
    input_paths = {
      "region"       = "$.region"
      "project-name" = "$.detail.project-name"
      "build-status" = "$.detail.build-status"
    }

    input_template = replace(
      replace(
        jsonencode(local.aws_cloudwatch_event_target_codebuild_input_template),
        "$",
        "<",
      ),
      "#",
      ">",
    )
  }
}

resource "aws_cloudwatch_event_rule" "CodeBuild_Build_State_virginia" {
  provider    = aws.virginia
  name        = "capture-CodeBuild-Build-State-events"
  description = "Capture all CodeBuild Build State events"

  event_pattern = <<PATTERN
  {
    "source": [ 
      "aws.codebuild"
    ], 
    "detail-type": [
      "CodeBuild Build State Change"
    ],
    "detail": {
      "build-status": [
        "IN_PROGRESS",
        "SUCCEEDED", 
        "FAILED",
        "STOPPED" 
      ]
    }  
  }
  PATTERN

}

resource "aws_cloudwatch_event_target" "CodeBuild_Build_State_virginia" {
  provider = aws.virginia
  target_id = "sns"
  rule = aws_cloudwatch_event_rule.CodeBuild_Build_State_virginia.name
  arn = aws_sns_topic.deployments-virginia.arn

  input_transformer {
    input_paths = {
      "region" = "$.region"
      "project-name" = "$.detail.project-name"
      "build-status" = "$.detail.build-status"
    }

  input_template = replace(
      replace(
          jsonencode(local.aws_cloudwatch_event_target_codebuild_input_template)
          ,"$","<",
      )
      ,"#",">",
    )
  }
}

Debug Output

https://gist.github.com/relifeted/c831f9521d8228c94ecd4deaa4996da4

Crash Output

https://gist.github.com/relifeted/c831f9521d8228c94ecd4deaa4996da4

Expected Behavior

finish plan

Actual Behavior

crashed

Steps to Reproduce

  1. terraform init
  2. terraform plan

Additional Context

References

@jbardin
Copy link
Member

jbardin commented Jun 21, 2019

Thanks for the bug report @relifeted,

There seems to be an unexpectedly nil instance in the state. The relevant stack trace is:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x1ad1ff3]

goroutine 2298 [running]:
github.com/hashicorp/terraform/terraform.(*evaluationStateData).getResourceInstancesAll(0xc0068413b0, 0x4d, 0xc000702820, 0x13, 0xc000948d40, 0xd, 0xc0007f6180, 0x33, 0xa, 0x1a, ...)
	/opt/gopath/src/github.com/hashicorp/terraform/terraform/evaluate.go:704 +0x11a3
github.com/hashicorp/terraform/terraform.(*evaluationStateData).GetResourceInstance(0xc0068413b0, 0x4d, 0xc000702820, 0x13, 0xc000948d40, 0xd, 0x0, 0x0, 0xc0007f6180, 0x33, ...)
	/opt/gopath/src/github.com/hashicorp/terraform/terraform/evaluate.go:593 +0x1360
github.com/hashicorp/terraform/lang.(*Scope).evalContext(0xc003bec5f0, 0xc001848fa0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0xc00089b520, 0xa)
	/opt/gopath/src/github.com/hashicorp/terraform/lang/eval.go:253 +0xfcc
github.com/hashicorp/terraform/lang.(*Scope).EvalContext(...)
	/opt/gopath/src/github.com/hashicorp/terraform/lang/eval.go:160
github.com/hashicorp/terraform/lang.(*Scope).EvalExpr(0xc003bec5f0, 0x2de8f60, 0xc000417e00, 0x2dea2a0, 0x3ee48d8, 0xc0014caa80, 0x0, 0xc0020c8768, 0x3, 0xc00004e570, ...)
	/opt/gopath/src/github.com/hashicorp/terraform/lang/eval.go:87 +0xb3
github.com/hashicorp/terraform/terraform.(*BuiltinEvalContext).EvaluateExpr(0xc0014c95f0, 0x2de8f60, 0xc000417e00, 0x2dea2a0, 0x3ee48d8, 0x0, 0x0, 0x3ec4c60, 0x56, 0x2a30f70, ...)
	/opt/gopath/src/github.com/hashicorp/terraform/terraform/eval_context_builtin.go:284 +0x1e4
github.com/hashicorp/terraform/terraform.(*EvalWriteOutput).Eval(0xc0019e23c0, 0x2e1c120, 0xc0014c95f0, 0x2, 0x2, 0xc001a20000, 0x53)
	/opt/gopath/src/github.com/hashicorp/terraform/terraform/eval_output.go:48 +0x153
github.com/hashicorp/terraform/terraform.EvalRaw(0x2da8d20, 0xc0019e23c0, 0x2e1c120, 0xc0014c95f0, 0x3e, 0x0, 0x0, 0x3e)
	/opt/gopath/src/github.com/hashicorp/terraform/terraform/eval.go:57 +0x131
github.com/hashicorp/terraform/terraform.(*EvalOpFilter).Eval(0xc0019e2420, 0x2e1c120, 0xc0014c95f0, 0x2, 0x2, 0xc0020c8b38, 0x102b231)
	/opt/gopath/src/github.com/hashicorp/terraform/terraform/eval_filter_operation.go:37 +0x4c
github.com/hashicorp/terraform/terraform.EvalRaw(0x2da8ae0, 0xc0019e2420, 0x2e1c120, 0xc0014c95f0, 0x14, 0xbf3b4a942b5c4bc8, 0x626428c9b, 0x3e)
	/opt/gopath/src/github.com/hashicorp/terraform/terraform/eval.go:57 +0x131
github.com/hashicorp/terraform/terraform.(*EvalSequence).Eval(0xc000c9ff40, 0x2e1c120, 0xc0014c95f0, 0x2, 0x2, 0x1abe1c5, 0x2da8ae0)
	/opt/gopath/src/github.com/hashicorp/terraform/terraform/eval_sequence.go:20 +0xfd
github.com/hashicorp/terraform/terraform.EvalRaw(0x2da8c20, 0xc000c9ff40, 0x2e1c120, 0xc0014c95f0, 0x2663a20, 0x3d9a404, 0x25d0da0, 0xc00148edb0)
	/opt/gopath/src/github.com/hashicorp/terraform/terraform/eval.go:57 +0x131
github.com/hashicorp/terraform/terraform.Eval(0x2da8c20, 0xc000c9ff40, 0x2e1c120, 0xc0014c95f0, 0xc000c9ff40, 0x2da8c20, 0xc000c9ff40, 0x0)
	/opt/gopath/src/github.com/hashicorp/terraform/terraform/eval.go:35 +0x4d
github.com/hashicorp/terraform/terraform.(*Graph).walk.func1(0x282c680, 0xc000a6a030, 0x0, 0x0, 0x0)
	/opt/gopath/src/github.com/hashicorp/terraform/terraform/graph.go:90 +0xf40
github.com/hashicorp/terraform/dag.(*Walker).walkVertex(0xc0007be980, 0x282c680, 0xc000a6a030, 0xc0015b47c0)
	/opt/gopath/src/github.com/hashicorp/terraform/dag/walk.go:392 +0x353
created by github.com/hashicorp/terraform/dag.(*Walker).Update
	/opt/gopath/src/github.com/hashicorp/terraform/dag/walk.go:314 +0xa9b

@xocasdashdash
Copy link
Contributor

@jbardin I think it's a dupe of another issue I have opened #21740 . Do you think this will be fixed in the 0.11.x series?

@jbardin
Copy link
Member

jbardin commented Jul 8, 2019

closed by #21979

@jbardin jbardin closed this as completed Jul 8, 2019
@ghost
Copy link

ghost commented Aug 13, 2019

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.

@ghost ghost locked and limited conversation to collaborators Aug 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants