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.36k stars 9.49k forks source link

terraform crash when import aws_eip #31141

Closed bfdy18 closed 2 years ago

bfdy18 commented 2 years ago

Terraform Version

$ terraform version
Terraform v1.1.8
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v3.75.2

Your version of Terraform is out of date! The latest version
is 1.2.1. You can update by downloading from https://www.terraform.io/downloads.html```

### Terraform Configuration Files
<!--
Paste the relevant parts of your Terraform configuration between the ``` marks below.

For Terraform configs larger than a few resources, or that involve multiple files, please make a GitHub repository that we can clone, rather than copy-pasting multiple files in here. For security, you can also encrypt the files using our GPG public key at https://www.hashicorp.com/security.
-->

```terraform
resource "aws_eip" "nat" {
  count = length(var.external_nat_ip_ids) > 0 ? 0 : local.nat_ip_counts

  vpc = true
  tags = {
    "Name" = "${local.vpc_name}-${var.availability_zones[count.index]}",
  }

  lifecycle {
    prevent_destroy = true
  }
}

Debug Output

Expected Behavior

Actual Behavior

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

AttributeTypes on non-object Type
goroutine 2498 [running]:
runtime/debug.Stack()
    /usr/local/go/src/runtime/debug/stack.go:24 +0x65
runtime/debug.PrintStack()
    /usr/local/go/src/runtime/debug/stack.go:16 +0x19
github.com/hashicorp/terraform/internal/logging.PanicHandler()
    /home/circleci/project/project/internal/logging/panic.go:55 +0x154
panic({0x21586a0, 0x2ad1d00})
    /usr/local/go/src/runtime/panic.go:1038 +0x215
github.com/zclconf/go-cty/cty.Type.AttributeTypes(...)
    /home/circleci/go/pkg/mod/github.com/zclconf/go-cty@v1.10.0/cty/object_type.go:187
github.com/zclconf/go-cty/cty/convert.unifyObjectTypesToMap({0xc004949500, 0x2, 0x2b52e48}, 0x1)
    /home/circleci/go/pkg/mod/github.com/zclconf/go-cty@v1.10.0/cty/convert/unify.go:368 +0x599
github.com/zclconf/go-cty/cty/convert.unifyTupleTypesToList({0xc004949500, 0x2, 0x2}, 0x1)
    /home/circleci/go/pkg/mod/github.com/zclconf/go-cty@v1.10.0/cty/convert/unify.go:487 +0x433
github.com/zclconf/go-cty/cty/convert.unifyTupleTypes({0xc004949500, 0x2, 0x2}, 0x1, 0x93)
    /home/circleci/go/pkg/mod/github.com/zclconf/go-cty@v1.10.0/cty/convert/unify.go:418 +0x69b
github.com/zclconf/go-cty/cty/convert.unify({0xc004949500, 0x2, 0x2}, 0x1)
    /home/circleci/go/pkg/mod/github.com/zclconf/go-cty@v1.10.0/cty/convert/unify.go:85 +0x41e
github.com/zclconf/go-cty/cty/convert.UnifyUnsafe(...)
    /home/circleci/go/pkg/mod/github.com/zclconf/go-cty@v1.10.0/cty/convert/public.go:82
github.com/hashicorp/hcl/v2/hclsyntax.(*ConditionalExpr).Value(0xc0006601c0, 0xc000428a98)
    /home/circleci/go/pkg/mod/github.com/hashicorp/hcl/v2@v2.11.1/hclsyntax/expression.go:609 +0x2bd
github.com/hashicorp/terraform/internal/lang.(*Scope).EvalExpr(0xc0009479e0, {0x2b519f0, 0xc0006601c0}, {{0x2b52e10, 0x409b020}})
    /home/circleci/project/project/internal/lang/eval.go:171 +0x14b
github.com/hashicorp/terraform/internal/terraform.(*BuiltinEvalContext).EvaluateExpr(0xc00244ca09, {0x2b519f0, 0xc0006601c0}, {{0x2b52e10, 0x409b020}}, {0x0, 0x0})
    /home/circleci/project/project/internal/terraform/eval_context_builtin.go:281 +0xc5
github.com/hashicorp/terraform/internal/terraform.(*NodeApplyableOutput).Execute(0xc003741cc0, {0x2bc72a0, 0xc0008e89a0}, 0x40)
    /home/circleci/project/project/internal/terraform/node_output.go:275 +0x293
github.com/hashicorp/terraform/internal/terraform.(*ContextGraphWalker).Execute(0xc00184a000, {0x2bc72a0, 0xc0008e89a0}, {0x7f9d05ee9e00, 0xc003741cc0})
    /home/circleci/project/project/internal/terraform/graph_walk_context.go:133 +0xc2
github.com/hashicorp/terraform/internal/terraform.(*Graph).walk.func1({0x2456e60, 0xc003741cc0})
    /home/circleci/project/project/internal/terraform/graph.go:74 +0x2f0
github.com/hashicorp/terraform/internal/dag.(*Walker).walkVertex(0xc000a8b560, {0x2456e60, 0xc003741cc0}, 0xc003741dc0)
    /home/circleci/project/project/internal/dag/walk.go:381 +0x2f1
created by github.com/hashicorp/terraform/internal/dag.(*Walker).Update
    /home/circleci/project/project/internal/dag/walk.go:304 +0xf85
ERRO[0006] 1 error occurred:
    * exit status 11

Steps to Reproduce

terragrunt import 'aws_eip.nat[1]' 52.22.18.132

Additional Context

References

ei-grad commented 2 years ago

Just got a similar crash on working with aws resources.

jbardin commented 2 years ago

Hello,

Thanks for filing the issue. In order to determine what may have caused the crash we need a more complete configuration example. If possible, could you supply the complete output and configuration which caused the crash?

Thanks!

jbardin commented 2 years ago

Hello, since we have not heard back with a reproduction, and have a similar report already for import, I'm going to close this out.

Thanks!

github-actions[bot] commented 2 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.