hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.76k stars 9.11k forks source link

Terraform crashes with panic: runtime error: invalid memory address or nil pointer dereference #4554

Closed ghost closed 6 years ago

ghost commented 6 years ago

This issue was originally opened by @nozpheratu as hashicorp/terraform#18061. It was migrated here as a result of the provider split. The original body of the issue is below.


Output from terraform -v: Terraform v0.11.7

It crashes due to the following block:

resource "aws_alb_target_group" "application" {
  name     = "test"
  vpc_id = "vpc-62df040a"
  port     = 80
  protocol = "TCP"
}

Here's the generated log:

Error: Error applying plan:

1 error(s) occurred:

* aws_alb_target_group.application: 1 error(s) occurred:

* aws_alb_target_group.application: unexpected EOF

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

panic: runtime error: invalid memory address or nil pointer dereference
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x28ab83d]
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4:
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4: goroutine 670 [running]:
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4: github.com/terraform-providers/terraform-provider-aws/aws.flattenAwsLbTargetGroupResource(0xc42025a4d0, 0x31685a0, 0xc4201bfb$
0, 0xc42030c090, 0x0, 0xc42025cf30)
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4:   /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_lb_tar$
et_group.go:529 +0x62d
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4: github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsLbTargetGroupRead(0xc42025a4d0, 0x31685a0, 0xc4201bfb80,
0x0, 0x0)
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4:   /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_lb_tar$
et_group.go:273 +0x28b
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4: github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsLbTargetGroupUpdate(0xc42025a4d0, 0x31685a0, 0xc4201bfb8$
, 0x0, 0x0)
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4:   /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_lb_tar$
et_group.go:371 +0x178
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4: github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsLbTargetGroupCreate(0xc42025a4d0, 0x31685a0, 0xc4201bfb80
, 0xc42025a4d0, 0x0)
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4:   /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_lb_targ
et_group.go:251 +0x8f9
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.(*Resource).Apply(0x
c420b316c0, 0xc42007c6e0, 0xc4202c3d40, 0x31685a0, 0xc4201bfb80, 0x1, 0xc420abfda0, 0x1010f0142a7c6db)
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4:   /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashic
orp/terraform/helper/schema/resource.go:227 +0x364
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.(*Provider).Apply(0x
c420b31960, 0xc42007c690, 0xc42007c6e0, 0xc4202c3d40, 0x5f7a000, 0x0, 0x1000)
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4:   /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashic
orp/terraform/helper/schema/provider.go:283 +0xa4
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/plugin.(*ResourceProviderServer).A
pply(0xc4207dc900, 0xc4202c3ce0, 0xc4208306b0, 0x0, 0x0)
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4:   /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashic
orp/terraform/plugin/resource_provider.go:527 +0x57
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4: reflect.Value.call(0xc420388780, 0xc42016c8e0, 0x13, 0x3569fe8, 0x4, 0xc420040f20, 0x3, 0x3, 0xc4204a3f28, 0x2, ...)
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4:   /usr/local/go/src/reflect/value.go:434 +0x905
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4: reflect.Value.Call(0xc420388780, 0xc42016c8e0, 0x13, 0xc4204a3f20, 0x3, 0x3, 0x50a3140, 0xc420778f60, 0xc4201ad220)
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4:   /usr/local/go/src/reflect/value.go:302 +0xa4
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4: net/rpc.(*service).call(0xc420ab22c0, 0xc42018d310, 0xc4202c56c0, 0xc420188600, 0xc4202c3c00, 0x2cd30a0, 0xc4202c3ce0, 0x16, 0
x2cd30e0, 0xc4208306b0, ...)
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4:   /usr/local/go/src/net/rpc/server.go:381 +0x142
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4: created by net/rpc.(*Server).ServeCodec
2018-05-16T09:33:22.939-0500 [DEBUG] plugin.terraform-provider-aws_v1.9.0_x4:   /usr/local/go/src/net/rpc/server.go:475 +0x36b
2018/05/16 09:33:22 [TRACE] root: eval: *terraform.EvalWriteState
2018/05/16 09:33:22 [TRACE] root: eval: *terraform.EvalApplyProvisioners
2018/05/16 09:33:22 [TRACE] root: eval: *terraform.EvalIf
2018/05/16 09:33:22 [TRACE] root: eval: *terraform.EvalWriteState
2018/05/16 09:33:22 [TRACE] root: eval: *terraform.EvalWriteDiff
2018/05/16 09:33:22 [TRACE] root: eval: *terraform.EvalApplyPost
2018/05/16 09:33:22 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* aws_alb_target_group.application: unexpected EOF
2018/05/16 09:33:22 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* aws_alb_target_group.application: unexpected EOF
2018/05/16 09:33:22 [TRACE] [walkApply] Exiting eval tree: aws_alb_target_group.application
2018/05/16 09:33:22 [TRACE] dag/walk: upstream errored, not walking "provider.aws (close)"
2018/05/16 09:33:22 [TRACE] dag/walk: upstream errored, not walking "meta.count-boundary (count boundary fixup)"
2018/05/16 09:33:22 [TRACE] dag/walk: upstream errored, not walking "root"
2018-05-16T09:33:22.942-0500 [DEBUG] plugin: plugin process exited: path=/Users/cyle/devops/stbf-aws/.terraform/plugins/darwin_amd64/terraform-provider-aws_v1.9.0_x4
2018/05/16 09:33:22 [TRACE] Preserving existing state lineage "0d72cda7-7e55-4c70-823f-ef2514e7c5bf"
2018/05/16 09:33:22 [TRACE] Preserving existing state lineage "0d72cda7-7e55-4c70-823f-ef2514e7c5bf"
2018/05/16 09:33:22 [TRACE] Preserving existing state lineage "0d72cda7-7e55-4c70-823f-ef2514e7c5bf"
2018/05/16 09:33:22 [DEBUG] plugin: waiting for all plugin processes to complete...
2018-05-16T09:33:22.949-0500 [WARN ] plugin: error closing client during Kill: err="connection is shut down"
2018-05-16T09:33:22.950-0500 [DEBUG] plugin.terraform: local-exec-provisioner (internal) 2018/05/16 09:33:22 [DEBUG] plugin: waiting for all plugin processes to complete...
2018-05-16T09:33:22.951-0500 [DEBUG] plugin: plugin process exited: path=/Users/cyle/devops/stbf-aws/.terraform/plugins/darwin_amd64/terraform-provider-null_v1.0.0_x4
2018-05-16T09:33:22.952-0500 [DEBUG] plugin: plugin process exited: path=/Users/cyle/bin/terraform

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version. That
information is available on the first line of crash.log. You can also
get it by running 'terraform --version' on the command line.

[1]: https://github.com/hashicorp/terraform/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Any ideas?

GonzaloLeyton commented 6 years ago

I'm having the same issue but with Azure provider

bflad commented 6 years ago

Hi @GonzaloLeyton 👋 please open an issue in the AzureRM provider repository -- the code lives in different places per provider.

@nozpheratu sorry you ran into trouble here. From this line number and AWS provider version it looks like you hit a known issue that was fixed.

Due to an ELBv2 service upgrade that started around March 27, 2018, the aws_lb_target_group resource you are using requires an update. The fix was previously released in version 1.13.0 of the AWS provider and has been available in all versions since. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!