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

aws_instance.credit_specification: panic: interface conversion: interface {} is nil, not map[string]interface {} #10203

Closed
dekimsey opened this issue Sep 23, 2019 · 5 comments · Fixed by #10212
Assignees
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/ec2 Issues and PRs that pertain to the ec2 service.
Milestone

Comments

@dekimsey
Copy link
Contributor

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.12.9
+ provider.aws v2.28.1
+ provider.azuread v0.6.0
+ provider.null v2.1.2
+ provider.random v2.2.0
+ provider.template v2.1.2
+ provider.tls v2.1.0

Affected Resource(s)

  • aws_instance

Terraform Configuration Files

module "elk-elasticsearch-hot" {
  source  = "terraform-aws-modules/ec2-instance/aws"
  version = "~> 2.8.0"
  name    = "${local.unique_namespace}-elk-elasticsearch-hot"

  ami           = data.aws_ami.centos-7.id
  instance_type = var.elk-elasticsearch-hot_instance_type[var.scale]

  subnet_ids = local.data-subnet-ids

  monitoring     = "true"
  use_num_suffix = "true"

  vpc_security_group_ids = [
    aws_security_group.common_management.id,
    aws_security_group.elk-elasticsearch.id,
    aws_security_group.elk-elasticsearch-hot.id,
  ]

  iam_instance_profile = aws_iam_instance_profile.elk-elasticsearch-hot.id
  user_data            = data.template_cloudinit_config.elk-elasticsearch-hot.rendered
  key_name             = aws_key_pair.provisioning.key_name

  instance_count = var.elk-elasticsearch-hot_desired_capacity[var.fault_tolerance]

  ebs_optimized = substr(var.elk-elasticsearch-hot_instance_type[var.scale], 0, 1) != "t" ? true : false

  root_block_device = [
    {
      volume_type           = "gp2"
      volume_size           = 8
      delete_on_termination = true
    },
  ]

  tags = {
    ansible_group = "elk-elasticsearch-hot"
    namespace     = local.unique_namespace
    application   = "elk"
    terraform     = "true"
  }
}

Debug Output

Panic Output

This is an excerpt from TF_LOG=debug that is dumped directly after the diff & prompt.

panic: interface conversion: interface {} is nil, not map[string]interface {}
2019-09-23T10:01:40.338-0500 [DEBUG] plugin.terraform-provider-aws_v2.28.1_x4:
2019-09-23T10:01:40.338-0500 [DEBUG] plugin.terraform-provider-aws_v2.28.1_x4: goroutine 25 [running]:
2019-09-23T10:01:40.338-0500 [DEBUG] plugin.terraform-provider-aws_v2.28.1_x4: github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsInstanceUpdate(0xc0002f6f50, 0x4af9620, 0xc000c6c000, 0x0, 0x0)
2019-09-23T10:01:40.338-0500 [DEBUG] plugin.terraform-provider-aws_v2.28.1_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_instance.go:1208 +0x4d57
2019-09-23T10:01:40.338-0500 [DEBUG] plugin.terraform-provider-aws_v2.28.1_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.(*Resource).Apply(0xc0002bff00, 0xc000768370, 0xc0008cf3e0, 0x4af9620, 0xc000c6c000, 0xc000ca3201, 0xa49c830, 0x5026240)
2019-09-23T10:01:40.338-0500 [DEBUG] plugin.terraform-provider-aws_v2.28.1_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema/resource.go:311 +0x264
2019-09-23T10:01:40.338-0500 [DEBUG] plugin.terraform-provider-aws_v2.28.1_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.(*Provider).Apply(0xc0006b7400, 0xc000cafa58, 0xc000768370, 0xc0008cf3e0, 0xc000d16748, 0xc00000e4d8, 0x5028a00)
2019-09-23T10:01:40.338-0500 [DEBUG] plugin.terraform-provider-aws_v2.28.1_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema/provider.go:289 +0x18f
2019-09-23T10:01:40.338-0500 [DEBUG] plugin.terraform-provider-aws_v2.28.1_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/plugin.(*GRPCProviderServer).ApplyResourceChange(0xc0005726c0, 0x63add40, 0xc000c26270, 0xc000b80360, 0xc0005726c0, 0xc000c26270, 0xc00095cbd0)
2019-09-23T10:01:40.338-0500 [DEBUG] plugin.terraform-provider-aws_v2.28.1_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/plugin/grpc_provider.go:885 +0x894
2019-09-23T10:01:40.338-0500 [DEBUG] plugin.terraform-provider-aws_v2.28.1_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x594a300, 0xc0005726c0, 0x63add40, 0xc000c26270, 0xc0007680a0, 0x0, 0x63add40, 0xc000c26270, 0xc000986000, 0x3624)
2019-09-23T10:01:40.338-0500 [DEBUG] plugin.terraform-provider-aws_v2.28.1_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/internal/tfplugin5/tfplugin5.pb.go:3217 +0x23e
2019-09-23T10:01:40.338-0500 [DEBUG] plugin.terraform-provider-aws_v2.28.1_x4: github.com/terraform-providers/terraform-provider-aws/vendor/google.golang.org/grpc.(*Server).processUnaryRPC(0xc000574c00, 0x63d0fe0, 0xc000575080, 0xc000c48000, 0xc0006c1260, 0xa49cea0, 0x0, 0x0, 0x0)
2019-09-23T10:01:40.338-0500 [DEBUG] plugin.terraform-provider-aws_v2.28.1_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/google.golang.org/grpc/server.go:971 +0x470
2019-09-23T10:01:40.338-0500 [DEBUG] plugin.terraform-provider-aws_v2.28.1_x4: github.com/terraform-providers/terraform-provider-aws/vendor/google.golang.org/grpc.(*Server).handleStream(0xc000574c00, 0x63d0fe0, 0xc000575080, 0xc000c48000, 0x0)
2019-09-23T10:01:40.338-0500 [DEBUG] plugin.terraform-provider-aws_v2.28.1_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/google.golang.org/grpc/server.go:1250 +0xd25
2019-09-23T10:01:40.338-0500 [DEBUG] plugin.terraform-provider-aws_v2.28.1_x4: github.com/terraform-providers/terraform-provider-aws/vendor/google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc00003a190, 0xc000574c00, 0x63d0fe0, 0xc000575080, 0xc000c48000)
2019-09-23T10:01:40.338-0500 [DEBUG] plugin.terraform-provider-aws_v2.28.1_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/google.golang.org/grpc/server.go:690 +0x9f
2019-09-23T10:01:40.338-0500 [DEBUG] plugin.terraform-provider-aws_v2.28.1_x4: created by github.com/terraform-providers/terraform-provider-aws/vendor/google.golang.org/grpc.(*Server).serveStreams.func1
2019-09-23T10:01:40.338-0500 [DEBUG] plugin.terraform-provider-aws_v2.28.1_x4: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/google.golang.org/grpc/server.go:688 +0xa1
2019/09/23 10:01:40 [DEBUG] module.elk-elasticsearch-hot.aws_instance.this[0]: apply errored, but we're indicating that via the Error pointer rather than returning it: rpc error: code = Unavailable desc = transport is closing

Expected Behavior

The aws_instance resource should have successfully been updated or NOOP'd the credit_specification, since this isn't a t2 instance.

Actual Behavior

$ terraform apply -target=module.elk-elasticsearch-hot.aws_instance.this[0]
...
module.elk-elasticsearch-hot.aws_instance.this[0]: Refreshing state... [id=i-0b3e9cd781e4eca90]

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # module.elk-elasticsearch-hot.aws_instance.this[0] will be updated in-place
  ~ resource "aws_instance" "this" {
        ami                          = "ami-0b4dd9d65556cac22"
        arn                          = "arn:aws:ec2:ap-southeast-1:210944854157:instance/i-0b3e9cd781e4eca90"
        associate_public_ip_address  = false
        availability_zone            = "ap-southeast-1a"
        cpu_core_count               = 4
        cpu_threads_per_core         = 2
        disable_api_termination      = false
        ebs_optimized                = true
        get_password_data            = false
        iam_instance_profile         = "apj-elk-elasticsearch-hot20190911195752163500000002"
        id                           = "i-0b3e9cd781e4eca90"
        instance_state               = "running"
        instance_type                = "c5d.2xlarge"
        ipv6_address_count           = 0
        ipv6_addresses               = []
        key_name                     = "apj-provisioning"
        monitoring                   = true
        primary_network_interface_id = "eni-0b0b82a4f11142c59"
        private_dns                  = "ip-10-115-20-147.ap-southeast-1.compute.internal"
        private_ip                   = "10.115.20.147"
        security_groups              = []
        source_dest_check            = true
        subnet_id                    = "subnet-0a92af603b6c63831"
        tags                         = {
            "Name"          = "apj-elk-elasticsearch-hot-1"
            "ansible_group" = "elk-elasticsearch-hot"
            "application"   = "elk"
            "namespace"     = "apj"
            "terraform"     = "true"
        }
        tenancy                      = "default"
        user_data                    = "d5030c29693988cedef90189165a0edd02353f3f"
        volume_tags                  = {
            "Name" = "apj-elk-elasticsearch-hot-1"
        }
        vpc_security_group_ids       = [
            "sg-02fe22fb82b468293",
            "sg-0e500f80414683d3d",
            "sg-0f72028c15a452f22",
        ]

      + credit_specification {}

        root_block_device {
            delete_on_termination = true
            encrypted             = true
            iops                  = 100
            kms_key_id            = "..."
            volume_id             = "vol-0f53323d854ad1f03"
            volume_size           = 8
            volume_type           = "gp2"
        }

        timeouts {}
    }

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

Do you want to perform these actions in workspace "apj"?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

module.elk-elasticsearch-hot.aws_instance.this[0]: Modifying... [id=i-0b3e9cd781e4eca90]

Error: rpc error: code = Unavailable desc = transport is closing

Steps to Reproduce

Encountered trying to run terraform 0.12 with latest aws provider during migration from 0.11.

  1. terraform apply

Important Factoids

Not that I'm aware of. This is the first-attempt to run an apply after migrating our states to 0.12.

References

@ghost ghost added bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/ec2 Issues and PRs that pertain to the ec2 service. labels Sep 23, 2019
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Sep 23, 2019
@dekimsey dekimsey changed the title aws_instance.credit_specification: panic: interface conversion: interface {} is nil, not map[string]interface {}triggering panic aws_instance.credit_specification: panic: interface conversion: interface {} is nil, not map[string]interface {} Sep 23, 2019
dekimsey added a commit to dekimsey/terraform-aws-ec2-instance that referenced this issue Sep 23, 2019
This is a workaround for terraform-aws-modules#128 and related upstream provider issue, [terraform-aws-provider#10203](hashicorp/terraform-provider-aws#10203).
@dekimsey
Copy link
Contributor Author

Patching the terraform-aws-ec2-instance module to make credit_specification a dynamic block appears to bypass the panic. See linked pull request.

@bflad bflad self-assigned this Sep 23, 2019
bflad added a commit that referenced this issue Sep 24, 2019
…ion` to empty configuration block

Reference: #10203

Previously before code fix:

```
=== CONT  TestAccAWSInstance_CreditSpecification_UnspecifiedToEmpty_NonBurstable
panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 1291 [running]:
github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsInstanceUpdate(0xc0004b2460, 0x524ba00, 0xc000b8e480, 0x0, 0x0)
	/Users/bflad/src/github.com/terraform-providers/terraform-provider-aws-deux/aws/resource_aws_instance.go:1208 +0x485b
```

Output from acceptance testing:

```
--- PASS: TestAccAWSInstance_CreditSpecification_UnspecifiedToEmpty_NonBurstable (135.98s)
```
@bflad bflad removed the needs-triage Waiting for first response or review from a maintainer. label Sep 24, 2019
@bflad
Copy link
Contributor

bflad commented Sep 24, 2019

Fix submitted: #10212

@bflad bflad added this to the v2.30.0 milestone Sep 24, 2019
@bflad
Copy link
Contributor

bflad commented Sep 24, 2019

The fix for this crash has been merged and will release with version 2.30.0 of the Terraform AWS Provider, later this week. 👍

@ghost
Copy link

ghost commented Sep 26, 2019

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

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

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

@ghost ghost locked and limited conversation to collaborators Nov 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
2 participants