Skip to content

Terraform AWS plugin crashes when destroying items #20131

@admin-edcomet

Description

@admin-edcomet

When running terraform destroy on our development environment, we received an error as below

Error: The terraform-provider-aws_v3.48.0_x5.exe plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

Hence, we are reporting this for general benefit.

As a work-around, we commented the resources causing the crash, then re-initialized terraform, ran the plan and the applied the plan. This caused the offending resources to be deleted. We then proceeded to destroy the rest of the infrastructure through the regular terraform destroy command.

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 other comments that do not add relevant new information or questions, 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 CLI and Terraform AWS Provider Version

Terraform v1.0.0 on windows_amd64
AWS provider from registry.terraform.io/hashicorp/aws version 3.48.0

Affected Resource(s)

The following resources gave error when destroying using the terraform destroy command

  • aws_launch_template
  • aws_alb

Terraform Configuration Files

Due to size, we cannot post the entire configuration. However, here are the configuration for the specific resources that were reported during the crash.

AWS Launch Template

resource "aws_launch_template" "this" {
  name_prefix          = "${var.application_name}-launch-template"
  image_id             = data.aws_ami.asg_ami.id
  key_name             = var.asg_key_name
  instance_type        = var.asg_instance_type
  user_data            = var.asg_user_data
  iam_instance_profile {
    name = aws_iam_instance_profile.iam_instance_profile.id
  }

  vpc_security_group_ids = concat([aws_security_group.instance_sg.id], var.asg_security_group_ids)

  lifecycle {
    create_before_destroy = true
  }

  tag_specifications {
    resource_type = "volume"
    tags = merge({
      Name = "${var.application_name}-volume"
    },
    var.base_tags
    )
  }

  tag_specifications {
    resource_type = "instance"
    tags = merge({
      Name = var.application_name
    },
    var.base_tags
    )
  }
}

ALB

resource "aws_alb" "main" {
  name = var.name

  internal        = var.internal
  security_groups = [aws_security_group.alb.id]
  subnets         = var.subnets
  idle_timeout    = var.idle_timeout

  dynamic "access_logs" {
    for_each = var.access_logs
    content {
      bucket  = access_logs.value.bucket
      enabled = access_logs.value.enabled
      prefix  = access_logs.value.prefix
    }
  }

  tags = merge(
    var.common_tags,
    {
      "Name" = var.name
    }
  )
}

Panic Output

https://gist.github.com/admin-edcomet/5c25892d10c5f4737343e38aaa63c2f2

Expected Behavior

Terraform destroy command should have destroyed all resources successfully

Actual Behavior

The AWS plugin crashed

Steps to Reproduce

terraform destroy

Important Factoids

An auto-scaling group was also created as part of this configuration. After creation, the EC2 instances was not moving to a healthy status in the target group (due to issues not related to Terraform), so we had manually changed the desired number of instances to 0 to avoid scaling activity during investigation. After we found the root cause, we needed to destroy and recreate the configurations. However, while we were destroying, the reported crash occurred.

References

This is similar to reported issues with other versions of Terraform and AWS provider plugin as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAddresses a defect in current functionality.crashResults from or addresses a Terraform crash or kernel panic.service/elbv2Issues and PRs that pertain to the elbv2 service.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions