Skip to content

NodeApplyableProvider Does Not Call ConfigureProvider for Destroy Plan With Deposed Instances #29712

@ewbankkit

Description

@ewbankkit

SDK version

% go list -m github.com/hashicorp/terraform-plugin-sdk/...
github.com/hashicorp/terraform-plugin-sdk/v2 v2.8.0 => github.com/gdavison/terraform-plugin-sdk/v2 v2.7.1-0.20210913224932-c7c2dbd9e010

We are running on a forked version of v2.7.1 but have seen this issue on prior unforked versions.

Configuration and steps to repro: hashicorp/terraform-provider-aws#21181.

Terraform Configuration Files

provider "aws" {}

resource "aws_api_gateway_rest_api" "this" {
  name = "Test API"
  body = "invalid OpenAPI spec"
}

resource "aws_api_gateway_deployment" "default" {
  rest_api_id = aws_api_gateway_rest_api.this.id

  triggers = {
    redeployment = sha1("invalid OpenAPI spec")
  }

  lifecycle {
    create_before_destroy = true
  }
}

resource "aws_api_gateway_stage" "default" {
  deployment_id = aws_api_gateway_deployment.default.id
  rest_api_id   = aws_api_gateway_rest_api.this.id
  stage_name    = "default"
}

Steps to Reproduce

% terraform apply
...
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_api_gateway_rest_api.this: Creating...

│ Error: error creating API Gateway specification: BadRequestException: Invalid OpenAPI input.

│   with aws_api_gateway_rest_api.this,
│   on main.tf line 3, in resource "aws_api_gateway_rest_api" "this":
│    3: resource "aws_api_gateway_rest_api" "this" {


% terraform apply
...
Plan: 3 to add, 0 to change, 1 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_api_gateway_rest_api.this: Creating...

│ Error: error creating API Gateway specification: BadRequestException: Invalid OpenAPI input.

│   with aws_api_gateway_rest_api.this,
│   on main.tf line 3, in resource "aws_api_gateway_rest_api" "this":
│    3: resource "aws_api_gateway_rest_api" "this" {


% terraform destroy
...
aws_api_gateway_rest_api.this: Refreshing state... [id=z9k6kjpm2e]
aws_api_gateway_rest_api.this (deposed object 11ed7aa0): Refreshing state... [id=kttrnchlwa]
aws_api_gateway_rest_api.this (deposed object 11ed7aa0): Refreshing state... [id=kttrnchlwa]

│ Error: Plugin did not respond

│   with aws_api_gateway_rest_api.this,
│   on main.tf line 3, in resource "aws_api_gateway_rest_api" "this":
│    3: resource "aws_api_gateway_rest_api" "this" {

│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ReadResource call. The plugin logs may contain more details.


Stack trace from the terraform-provider-aws plugin:

panic: interface conversion: interface {} is nil, not *aws.AWSClient

goroutine 69 [running]:
github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsApiGatewayRestApiRead(0xc000776a80, 0x0, 0x0, 0xc976ad0, 0xc000680000)
	/Users/ewbankkit/altsrc/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_api_gateway_rest_api.go:328 +0x1aca
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc000894c40, 0x8eb88c8, 0xc00075e5c0, 0xc000776a80, 0x0, 0x0, 0x0, 0x0, 0x0)
	/Users/ewbankkit/go/pkg/mod/github.com/gdavison/terraform-plugin-sdk/v2@v2.7.1-0.20210913224932-c7c2dbd9e010/helper/schema/resource.go:335 +0x1ee
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc000894c40, 0x8eb88c8, 0xc00075e5c0, 0xc00077a540, 0x0, 0x0, 0xc00077e400, 0x0, 0x0, 0x0)
	/Users/ewbankkit/go/pkg/mod/github.com/gdavison/terraform-plugin-sdk/v2@v2.7.1-0.20210913224932-c7c2dbd9e010/helper/schema/resource.go:624 +0x1cb
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc000112828, 0x8eb88c8, 0xc00075e5c0, 0xc00075e600, 0xc00075e5c0, 0x100d165, 0x7d913a0)
	/Users/ewbankkit/go/pkg/mod/github.com/gdavison/terraform-plugin-sdk/v2@v2.7.1-0.20210913224932-c7c2dbd9e010/helper/schema/grpc_provider.go:575 +0x43b
github.com/hashicorp/terraform-plugin-go/tfprotov5/server.(*server).ReadResource(0xc000753120, 0x8eb8970, 0xc00075e5c0, 0xc00076a540, 0xc000753120, 0xc001e60150, 0xc000092ba0)
	/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.3.0/tfprotov5/server/server.go:298 +0x105
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler(0x80885e0, 0xc000753120, 0x8eb8970, 0xc001e60150, 0xc00076a4e0, 0x0, 0x8eb8970, 0xc001e60150, 0xc001e17c00, 0x1e9)
	/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.3.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:344 +0x214
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0004b16c0, 0x8edc8b8, 0xc0022ba600, 0xc00076c200, 0xc001301260, 0xc935370, 0x0, 0x0, 0x0)
	/Users/ewbankkit/go/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:1194 +0x52b
google.golang.org/grpc.(*Server).handleStream(0xc0004b16c0, 0x8edc8b8, 0xc0022ba600, 0xc00076c200, 0x0)
	/Users/ewbankkit/go/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:1517 +0xd0c
google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc0014aecd0, 0xc0004b16c0, 0x8edc8b8, 0xc0022ba600, 0xc00076c200)
	/Users/ewbankkit/go/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:859 +0xab
created by google.golang.org/grpc.(*Server).serveStreams.func1
	/Users/ewbankkit/go/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:857 +0x1fd

Error: The terraform-provider-aws 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.

References

Relates:

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions