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.74k stars 9.1k forks source link

[Bug]: Error: The terraform-provider-aws_v5.32.1_x5 plugin crashed! #35363

Open Hardcoreyoyo opened 8 months ago

Hardcoreyoyo commented 8 months ago

Terraform Core Version

1.5.7, 1.7.0

AWS Provider Version

5.1.0, 5.32.1

Affected Resource(s)

aws_lightsail_distribution

Expected Behavior

AWS Lightsail distribution resource parameters modified successfully.

Actual Behavior

crashed

Relevant Error/Panic Output Snippet

terraform apply

aws_lightsail_static_ip.hcl-crash-test: Refreshing state... [id=hcl-crash-test-static-ip]
aws_lightsail_instance.hcl-crash-test-instance: Refreshing state... [id=hcl-crash-test-instance]
aws_lightsail_static_ip_attachment.hcl-crash-test-ip-attachment: Refreshing state... [id=hcl-crash-test-static-ip]
aws_lightsail_distribution.hcl-crash-test-distribution: Refreshing state... [id=hcl-crash-test-distribution2222]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the
following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # aws_lightsail_distribution.hcl-crash-test-distribution will be updated in-place
  ~ resource "aws_lightsail_distribution" "hcl-crash-test-distribution" {
        id                       = "hcl-crash-test-distribution2222"
        name                     = "hcl-crash-test-distribution2222"
        tags                     = {
            "foo" = "bar"
        }
        # (13 unchanged attributes hidden)

      - cache_behavior_settings {
        }

      ~ default_cache_behavior {
          ~ behavior = "dont-cache" -> "cache"
        }

      ~ origin {
            name            = "hcl-crash-test-instance"
          - protocol_policy = "http-only" -> null
            # (2 unchanged attributes hidden)
        }
    }

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

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

  Enter a value: yes

aws_lightsail_distribution.hcl-crash-test-distribution: Modifying... [id=hcl-crash-test-distribution2222]
╷
│ Error: Plugin did not respond
│
│   with aws_lightsail_distribution.hcl-crash-test-distribution,
│   on test.tf line 22, in resource "aws_lightsail_distribution" "hcl-crash-test-distribution":
│   22: resource "aws_lightsail_distribution" "hcl-crash-test-distribution" {
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin
│ logs may contain more details.
╵

Stack trace from the terraform-provider-aws_v5.32.1_x5 plugin:

panic: runtime error: index out of range [0] with length 0

goroutine 315 [running]:
github.com/hashicorp/terraform-provider-aws/internal/service/lightsail.resourceDistributionUpdate({0x111f72a0, 0xc002649e90}, 0xc000a7a400, {0xfbc6da0?, 0xc000166700})
    github.com/hashicorp/terraform-provider-aws/internal/service/lightsail/distribution.go:470 +0x1a9b
github.com/hashicorp/terraform-provider-aws/internal/provider.interceptedHandler[...].func1(0x0?, {0xfbc6da0?, 0xc000166700?})
    github.com/hashicorp/terraform-provider-aws/internal/provider/intercept.go:112 +0x32d
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0x111f72a0?, {0x111f72a0?, 0xc0025dd860?}, 0xd?, {0xfbc6da0?, 0xc000166700?})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/resource.go:807 +0x87
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc00171c9a0, {0x111f72a0, 0xc0025dd860}, 0xc00259ba00, 0xc000a7a280, {0xfbc6da0, 0xc000166700})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/resource.go:919 +0x845
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc003dd9f38, {0x111f72a0?, 0xc0025dd740?}, 0xc0003080f0)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/grpc_provider.go:1074 +0xe8d
github.com/hashicorp/terraform-plugin-mux/tf5muxserver.(*muxServer).ApplyResourceChange(0x111f71f8?, {0x111f72a0?, 0xc0025dd410?}, 0xc0003080f0)
    github.com/hashicorp/terraform-plugin-mux@v0.13.0/tf5muxserver/mux_server_ApplyResourceChange.go:36 +0x1b5
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc00071c5a0, {0x111f72a0?, 0xc0025dca20?}, 0xc0003118f0)
    github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov5/tf5server/server.go:859 +0x574
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xf996040?, 0xc00071c5a0}, {0x111f72a0, 0xc0025dca20}, 0xc000503800, 0x0)
    github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:503 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00102a3c0, {0x111f72a0, 0xc0025dc990}, {0x1120bec0, 0xc0001d2680}, 0xc0025db440, 0xc002866990, 0x17dfd758, 0x0)
    google.golang.org/grpc@v1.60.0/server.go:1372 +0xe49
google.golang.org/grpc.(*Server).handleStream(0xc00102a3c0, {0x1120bec0, 0xc0001d2680}, 0xc0025db440)
    google.golang.org/grpc@v1.60.0/server.go:1783 +0x1031
google.golang.org/grpc.(*Server).serveStreams.func2.1()
    google.golang.org/grpc@v1.60.0/server.go:1016 +0x68
created by google.golang.org/grpc.(*Server).serveStreams.func2
    google.golang.org/grpc@v1.60.0/server.go:1027 +0x12e

Error: The terraform-provider-aws_v5.32.1_x5 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.

Terraform Configuration Files

provider.tf

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }

  required_version = ">= 1.5.4"
}

provider "aws" {
  region  = "ap-northeast-1"
  profile = "CI_DevOps"
}

provider "aws" {
  alias  = "virginia"
  region = "us-east-1"
  profile = "CI_DevOps"
}

test.tf

resource "aws_lightsail_static_ip" "hcl-crash-test" {
  name = "hcl-crash-test-static-ip"
}

resource "aws_lightsail_instance" "hcl-crash-test-instance" {
  depends_on = [aws_lightsail_static_ip.hcl-crash-test]
  name              = "hcl-crash-test-instance"
  availability_zone = "ap-northeast-1a"
  blueprint_id      = "ubuntu_22_04"
  bundle_id         = "nano_3_0"
  ip_address_type = "ipv4"
  tags = {
    foo = "bar"
  }
}

resource "aws_lightsail_static_ip_attachment" "hcl-crash-test-ip-attachment" {
  static_ip_name = aws_lightsail_static_ip.hcl-crash-test.id
  instance_name  = aws_lightsail_instance.hcl-crash-test-instance.id
}

resource "aws_lightsail_distribution" "hcl-crash-test-distribution" {
  provider = aws.virginia
  depends_on = [aws_lightsail_static_ip_attachment.hcl-crash-test-ip-attachment]
  name       = "hcl-crash-test-distribution2222"
  bundle_id  = "small_1_0"
  origin {
    name        = aws_lightsail_instance.hcl-crash-test-instance.name
    region_name = "ap-northeast-1"
  }
  default_cache_behavior {
    behavior = "cache"
  }
  tags = {
    foo = "bar"
  }
}

Steps to Reproduce

Executed terraform plan successfully. Execution terraform apply failed.

Debug Output

terraform apply

aws_lightsail_static_ip.hcl-crash-test: Refreshing state... [id=hcl-crash-test-static-ip]
aws_lightsail_instance.hcl-crash-test-instance: Refreshing state... [id=hcl-crash-test-instance]
aws_lightsail_static_ip_attachment.hcl-crash-test-ip-attachment: Refreshing state... [id=hcl-crash-test-static-ip]
aws_lightsail_distribution.hcl-crash-test-distribution: Refreshing state... [id=hcl-crash-test-distribution2222]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the
following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # aws_lightsail_distribution.hcl-crash-test-distribution will be updated in-place
  ~ resource "aws_lightsail_distribution" "hcl-crash-test-distribution" {
        id                       = "hcl-crash-test-distribution2222"
        name                     = "hcl-crash-test-distribution2222"
        tags                     = {
            "foo" = "bar"
        }
        # (13 unchanged attributes hidden)

      - cache_behavior_settings {
        }

      ~ default_cache_behavior {
          ~ behavior = "dont-cache" -> "cache"
        }

      ~ origin {
            name            = "hcl-crash-test-instance"
          - protocol_policy = "http-only" -> null
            # (2 unchanged attributes hidden)
        }
    }

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

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

  Enter a value: yes

aws_lightsail_distribution.hcl-crash-test-distribution: Modifying... [id=hcl-crash-test-distribution2222]
╷
│ Error: Plugin did not respond
│
│   with aws_lightsail_distribution.hcl-crash-test-distribution,
│   on test.tf line 22, in resource "aws_lightsail_distribution" "hcl-crash-test-distribution":
│   22: resource "aws_lightsail_distribution" "hcl-crash-test-distribution" {
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin
│ logs may contain more details.
╵

Stack trace from the terraform-provider-aws_v5.32.1_x5 plugin:

panic: runtime error: index out of range [0] with length 0

goroutine 315 [running]:
github.com/hashicorp/terraform-provider-aws/internal/service/lightsail.resourceDistributionUpdate({0x111f72a0, 0xc002649e90}, 0xc000a7a400, {0xfbc6da0?, 0xc000166700})
    github.com/hashicorp/terraform-provider-aws/internal/service/lightsail/distribution.go:470 +0x1a9b
github.com/hashicorp/terraform-provider-aws/internal/provider.interceptedHandler[...].func1(0x0?, {0xfbc6da0?, 0xc000166700?})
    github.com/hashicorp/terraform-provider-aws/internal/provider/intercept.go:112 +0x32d
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0x111f72a0?, {0x111f72a0?, 0xc0025dd860?}, 0xd?, {0xfbc6da0?, 0xc000166700?})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/resource.go:807 +0x87
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc00171c9a0, {0x111f72a0, 0xc0025dd860}, 0xc00259ba00, 0xc000a7a280, {0xfbc6da0, 0xc000166700})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/resource.go:919 +0x845
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc003dd9f38, {0x111f72a0?, 0xc0025dd740?}, 0xc0003080f0)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/grpc_provider.go:1074 +0xe8d
github.com/hashicorp/terraform-plugin-mux/tf5muxserver.(*muxServer).ApplyResourceChange(0x111f71f8?, {0x111f72a0?, 0xc0025dd410?}, 0xc0003080f0)
    github.com/hashicorp/terraform-plugin-mux@v0.13.0/tf5muxserver/mux_server_ApplyResourceChange.go:36 +0x1b5
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc00071c5a0, {0x111f72a0?, 0xc0025dca20?}, 0xc0003118f0)
    github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov5/tf5server/server.go:859 +0x574
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xf996040?, 0xc00071c5a0}, {0x111f72a0, 0xc0025dca20}, 0xc000503800, 0x0)
    github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:503 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00102a3c0, {0x111f72a0, 0xc0025dc990}, {0x1120bec0, 0xc0001d2680}, 0xc0025db440, 0xc002866990, 0x17dfd758, 0x0)
    google.golang.org/grpc@v1.60.0/server.go:1372 +0xe49
google.golang.org/grpc.(*Server).handleStream(0xc00102a3c0, {0x1120bec0, 0xc0001d2680}, 0xc0025db440)
    google.golang.org/grpc@v1.60.0/server.go:1783 +0x1031
google.golang.org/grpc.(*Server).serveStreams.func2.1()
    google.golang.org/grpc@v1.60.0/server.go:1016 +0x68
created by google.golang.org/grpc.(*Server).serveStreams.func2
    google.golang.org/grpc@v1.60.0/server.go:1027 +0x12e

Error: The terraform-provider-aws_v5.32.1_x5 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.

Panic Output

No response

Important Factoids

macOS Monterey Version 12.6.8 MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports) CPU 2 GHz Quad-Core Intel Core i5 Memory 32 GB 3733 MHz LPDDR4X GPU Intel Iris Plus Graphics 1536 MB

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 8 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue