weixin_39717598
2021-01-12 08:05 阅读 0

Terraform Crash during Terraform apply

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

Terraform Version

Terraform v0.11.11 + provider.aws v1.57.0

Terraform Configuration Files

hcl
resource "aws_s3_bucket" "bucket" {
  bucket = "bucket"
  acl    = "private"
  cors_rule {
    allowed_headers = ["*"]
    allowed_methods = ["GET", "HEAD"]
    allowed_origins = ["*"]
    max_age_seconds = 86400
  }
  logging {
    target_bucket = "target-bucket"
    target_prefix = "s3-logs/"
  }
   website {
    index_document = "index.html"
  }

  replication_configuration {
    role = "${module.bucket-replication.replication-role-arn}"
    rules {
      destination {
        bucket = "${module.bucket-replication.bucket-dr-arn}"
        replica_kms_key_id = "${data.aws_kms_key.east-s3.arn}"
      }

      id = "replication-role-for-bucket"
      priority = 1
      source_selection_criteria {
        sse_kms_encrypted_objects {
          enabled = true
        }
      }

      status = "Enabled"

    }
  }

}


Debug Output

Crash Output

hcl
2019/01/31 17:48:32 [INFO] Terraform version: 0.11.11  
2019/01/31 17:48:32 [INFO] Go runtime version: go1.11.4
2019/01/31 17:48:32 [INFO] CLI args: []string{"/usr/local/Cellar/terraform/0.11.11/bin/terraform", "apply"}
2019/01/31 17:48:32 [DEBUG] Attempting to open CLI config file: /Users/lizhifan/.terraformrc
2019/01/31 17:48:32 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2019/01/31 17:48:32 [INFO] CLI command args: []string{"apply"}

2019/01/31 17:48:32 [INFO] command: empty terraform config, returning nil
2019/01/31 17:48:32 [TRACE] Preserving existing state lineage "ebdf2718-a158-36a6-9c63-dce214ec779d"
2019/01/31 17:48:32 [TRACE] Preserving existing state lineage "ebdf2718-a158-36a6-9c63-dce214ec779d"
2019/01/31 17:48:32 [INFO] command: backend initialized: <nil>
2019/01/31 17:48:32 [DEBUG] checking for provider in "."
2019/01/31 17:48:32 [DEBUG] checking for provider in "/usr/local/Cellar/terraform/0.11.11/bin"
2019/01/31 17:48:32 [DEBUG] checking for provider in ".terraform/plugins/darwin_amd64"
2019/01/31 17:48:32 [DEBUG] found provider "terraform-provider-aws_v1.57.0_x4"
2019/01/31 17:48:32 [DEBUG] found valid plugin: "aws", "1.57.0", 
...
2019/01/31 17:48:33 [TRACE] Graph after step *terraform.ConfigTransformer:

aws_s3_bucket.bucket - *terraform.NodeAbstractResource
</nil>

Expected Behavior


Terraform will perform the following actions:

  ~ aws_s3_bucket.bucket
      acl:           "" => "private"
      force_destroy: "" => "false"

  ~ module.bucket-replication.aws_s3_bucket.bucket-dr
      acl:           "" => "private"
      force_destroy: "" => "false"

Plan: 0 to add, 2 to change, 0 to destroy.

Actual Behavior


panic: interface conversion: interface {} is nil, not map[string]interface {}
2019-02-01T10:45:18.800-0800 [DEBUG] plugin.terraform-provider-aws_v1.57.0_x4: 
2019-02-01T10:45:18.800-0800 [DEBUG] plugin.terraform-provider-aws_v1.57.0_x4: goroutine 5945 [running]:
2019-02-01T10:45:18.800-0800 [DEBUG] plugin.terraform-provider-aws_v1.57.0_x4: github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsS3BucketReplicationConfigurationUpdate(0xc00114a5b8, 0xc0007f9960, 0x19, 0x1)
2019-02-01T10:45:18.801-0800 [DEBUG] plugin.terraform-provider-aws_v1.57.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_s3_bucket.go:1934 +0x1b7d
2019-02-01T10:45:18.801-0800 [DEBUG] plugin.terraform-provider-aws_v1.57.0_x4: github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsS3BucketUpdate(0xc0007f9960, 0x3e87de0, 0xc0007af000, 0x24, 0x7a22080)
2019-02-01T10:45:18.801-0800 [DEBUG] plugin.terraform-provider-aws_v1.57.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_s3_bucket.go:731 +0x524
2019-02-01T10:45:18.801-0800 [DEBUG] plugin.terraform-provider-aws_v1.57.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.(*Resource).Apply(0xc0012f9dc0, 0xc001310a00, 0xc0006436a0, 0x3e87de0, 0xc0007af000, 0x100b601, 0xc000089b80, 0x10bdabc)
2019-02-01T10:45:18.801-0800 [DEBUG] plugin.terraform-provider-aws_v1.57.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema/resource.go:231 +0x250
2019-02-01T10:45:18.801-0800 [DEBUG] plugin.terraform-provider-aws_v1.57.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.(*Provider).Apply(0xc000df7d50, 0xc0013109b0, 0xc001310a00, 0xc0006436a0, 0xc000075800, 0x18, 0x9099d80)
2019-02-01T10:45:18.801-0800 [DEBUG] plugin.terraform-provider-aws_v1.57.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema/provider.go:283 +0x9c
2019-02-01T10:45:18.801-0800 [DEBUG] plugin.terraform-provider-aws_v1.57.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/plugin.(*ResourceProviderServer).Apply(0xc000640e80, 0xc000643240, 0xc000655350, 0x0, 0x0)
2019-02-01T10:45:18.801-0800 [DEBUG] plugin.terraform-provider-aws_v1.57.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/plugin/resource_provider.go:527 +0x57
2019-02-01T10:45:18.801-0800 [DEBUG] plugin.terraform-provider-aws_v1.57.0_x4: reflect.Value.call(0xc0001566c0, 0xc00114bac0, 0x13, 0x45329c7, 0x4, 0xc000089f18, 0x3, 0x3, 0xc00013a100, 0xc0003b3400, ...)
2019-02-01T10:45:18.801-0800 [DEBUG] plugin.terraform-provider-aws_v1.57.0_x4:  /opt/goenv/versions/1.11.4/src/reflect/value.go:447 +0x454
2019-02-01T10:45:18.801-0800 [DEBUG] plugin.terraform-provider-aws_v1.57.0_x4: reflect.Value.Call(0xc0001566c0, 0xc00114bac0, 0x13, 0xc0005a6f18, 0x3, 0x3, 0x1b, 0x0, 0xc000a4b640)
2019-02-01T10:45:18.801-0800 [DEBUG] plugin.terraform-provider-aws_v1.57.0_x4:  /opt/goenv/versions/1.11.4/src/reflect/value.go:308 +0xa4
2019-02-01T10:45:18.801-0800 [DEBUG] plugin.terraform-provider-aws_v1.57.0_x4: net/rpc.(*service).call(0xc001209ac0, 0xc000536d20, 0xc0006be2e8, 0xc0006be300, 0xc000f15500, 0xc000641740, 0x384f440, 0xc000643240, 0x16, 0x384f480, ...)
2019-02-01T10:45:18.801-0800 [DEBUG] plugin.terraform-provider-aws_v1.57.0_x4:  /opt/goenv/versions/1.11.4/src/net/rpc/server.go:384 +0x14e
2019-02-01T10:45:18.801-0800 [DEBUG] plugin.terraform-provider-aws_v1.57.0_x4: created by net/rpc.(*Server).ServeCodec
2019-02-01T10:45:18.801-0800 [DEBUG] plugin.terraform-provider-aws_v1.57.0_x4:  /opt/goenv/versions/1.11.4/src/net/rpc/server.go:481 +0x47e
2019/02/01 10:45:18 [TRACE] root: eval: *terraform.EvalWriteState
2019/02/01 10:45:18 [TRACE] root: eval: *terraform.EvalApplyProvisioners
2019/02/01 10:45:18 [TRACE] root: eval: *terraform.EvalIf
2019/02/01 10:45:18 [TRACE] root: eval: *terraform.EvalWriteState
2019/02/01 10:45:18 [TRACE] root: eval: *terraform.EvalWriteDiff
2019/02/01 10:45:18 [TRACE] root: eval: *terraform.EvalApplyPost
2019/02/01 10:45:18 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* aws_s3_bucket.figma-alpha-api: unexpected EOF
2019/02/01 10:45:18 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* aws_s3_bucket.figma-alpha-api: unexpected EOF
2019/02/01 10:45:18 [TRACE] [walkApply] Exiting eval tree: aws_s3_bucket.figma-alpha-api
2019/02/01 10:45:18 [TRACE] dag/walk: upstream errored, not walking "provider.aws (close)"
2019/02/01 10:45:18 [TRACE] dag/walk: upstream errored, not walking "meta.count-boundary (count boundary fixup)"
2019/02/01 10:45:18 [TRACE] dag/walk: upstream errored, not walking "root"
2019-02-01T10:45:18.805-0800 [DEBUG] plugin: plugin process exited: path=/Users/lizhifan/figma/figma/config/terraform/prod/us-west-2/.terraform/plugins/darwin_amd64/terraform-provider-aws_v1.57.0_x4
2019/02/01 10:45:18 [TRACE] Preserving existing state lineage "bbb9ed33-3d8a-fd69-6079-acdd2e010423"
2019/02/01 10:45:18 [TRACE] Preserving existing state lineage "bbb9ed33-3d8a-fd69-6079-acdd2e010423"
2019/02/01 10:45:18 [TRACE] Preserving existing state lineage "bbb9ed33-3d8a-fd69-6079-acdd2e010423"
2019/02/01 10:45:18 [TRACE] Preserving existing state lineage "bbb9ed33-3d8a-fd69-6079-acdd2e010423"
2019/02/01 10:45:18 [DEBUG] plugin: waiting for all plugin processes to complete...
2019-02-01T10:45:18.860-0800 [WARN ] plugin: error closing client during Kill: err="connection is shut down"



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

该提问来源于开源项目:terraform-providers/terraform-provider-aws

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

10条回答 默认 最新

  • weixin_39574555 weixin_39574555 2021-01-12 08:05

    Do we know why this happen. This happen a lot of time for us also.

    点赞 评论 复制链接分享
  • weixin_39950552 weixin_39950552 2021-01-12 08:05

    can you please provide the Terraform crash output for your situation (e.g. the output starting at panic: and the first few lines of the stacktrace)? We will want to verify we are fixing your issue as well.

    点赞 评论 复制链接分享
  • weixin_39574555 weixin_39574555 2021-01-12 08:05

    Yeah, will activate the trace log... will keep you updated when this will occurs in another time

    点赞 评论 复制链接分享
  • weixin_39574555 weixin_39574555 2021-01-12 08:05

    We got one.... but i don't have any panic.

    点赞 评论 复制链接分享
  • weixin_39950552 weixin_39950552 2021-01-12 08:05

    I'd recommend opening a separate GitHub issue filling out the issue template details so we can appropriately triage.

    Hi 👋 Sorry you ran into this unexpected behavior. I'm having a difficult time reproducing this exact failure using a configuration similar to yours above.

    hcl
    resource "aws_s3_bucket" "bucket" {
        bucket   = "tf-test-bucket"
        acl      = "private"
    
        versioning {
            enabled = true
        }
    
        replication_configuration {
            role = "${aws_iam_role.role.arn}"
            rules {
                id       = "foobar"
                priority = 1
                status   = "Enabled"
    
                destination {
                    bucket = "${aws_s3_bucket.destination.arn}"
                }
            }
        }
    }
    

    The crash should be due to the resource expecting filter to always have nested arguments if it is defined, e.g.

    hcl
    resource "aws_s3_bucket" "bucket" {
        # ... other configuration ...
    
        replication_configuration {
            # ... other configuration ...
            rules {
                # ... other configuration ...
                # This seems like what should be causing the crash, but does not crash:
                filter {}
                # Neither does other odd configurations allowed in Terraform 0.11 that are no longer allowed in Terraform 0.12
                # filter = []
                # filter = [{}]
            }
        }
    }
    

    Can you please provide any other relevant details about when or how this occurred? Was this during resource creation, resource update, import, Terraform AWS Provider upgrade, etc? Thanks.

    点赞 评论 复制链接分享
  • weixin_39950552 weixin_39950552 2021-01-12 08:05

    This is similar to #6600, however as mentioned in that issue and above, we'll want additional details about what triggers the issue to ensure we properly fix it and prevent regressions in the future.

    点赞 评论 复制链接分享
  • weixin_39950552 weixin_39950552 2021-01-12 08:05

    Best effort fix submitted due to lack of issue replication: #7887

    点赞 评论 复制链接分享
  • weixin_39950552 weixin_39950552 2021-01-12 08:05

    The fix mentioned above has been merged and will release with version 2.2.0 of the Terraform AWS Provider, likely later today.

    点赞 评论 复制链接分享
  • weixin_39950552 weixin_39950552 2021-01-12 08:05

    This has been released in version 2.2.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

    点赞 评论 复制链接分享
  • weixin_39717598 weixin_39717598 2021-01-12 08:05

    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!

    点赞 评论 复制链接分享

相关推荐