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.64k stars 9.02k forks source link

[Bug]: Error: Plugin did not respond -> panic: interface conversion: interface {} is string, not int #32588

Closed x4team closed 1 year ago

x4team commented 1 year ago

Terraform Core Version

1.5.3

AWS Provider Version

5.8.0

Affected Resource(s)

aws_ec2_traffic_mirror_filter_rule

Expected Behavior

Recreate the inbound/output rules with a different "Rule number". For example, from 2 to 1

Actual Behavior

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

panic: interface conversion: interface {} is string, not int

Relevant Error/Panic Output Snippet

│ Error: Plugin did not respond
│ 
│   with module.suricata.aws_ec2_traffic_mirror_filter_rule.rule["all_out"],
│   on ../../../modules/suricata/main.tf line 92, in resource "aws_ec2_traffic_mirror_filter_rule" "rule":
│   92: resource "aws_ec2_traffic_mirror_filter_rule" "rule" {
│ 
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange
│ call. The plugin logs may contain more details.
╵
╷
│ Error: Plugin did not respond
│ 
│   with module.suricata.aws_ec2_traffic_mirror_filter_rule.rule["all_in"],
│   on ../../../modules/suricata/main.tf line 92, in resource "aws_ec2_traffic_mirror_filter_rule" "rule":
│   92: resource "aws_ec2_traffic_mirror_filter_rule" "rule" {
│ 
│ 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.8.0_x5 plugin:

panic: interface conversion: interface {} is string, not int

goroutine 349 [running]:
github.com/hashicorp/terraform-provider-aws/internal/service/ec2.resourceTrafficMirrorFilterRuleUpdate({0xf387580, 0xc00377acf0}, 0xc0043dcd00, {0xe06f840?, 0xc002857860?})
    github.com/hashicorp/terraform-provider-aws/internal/service/ec2/vpc_traffic_mirror_filter_rule.go:259 +0x1134
github.com/hashicorp/terraform-provider-aws/internal/provider.interceptedHandler[...].func1(0x0?, {0xe06f840?, 0xc002857860?})
    github.com/hashicorp/terraform-provider-aws/internal/provider/intercept.go:111 +0x34b
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0xf387580?, {0xf387580?, 0xc003765110?}, 0xd?, {0xe06f840?, 0xc002857860?})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.27.0/helper/schema/resource.go:762 +0x87
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0010cc2a0, {0xf387580, 0xc003765110}, 0xc00372b2b0, 0xc0043dcb80, {0xe06f840, 0xc002857860})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.27.0/helper/schema/resource.go:874 +0x845
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc00357f2d8, {0xf387580?, 0xc003764ff0?}, 0xc003d09810)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.27.0/helper/schema/grpc_provider.go:1024 +0xe8d
github.com/hashicorp/terraform-plugin-mux/tf5muxserver.muxServer.ApplyResourceChange({0xc002858f90, 0xc004ef5780, 0xc002858fc0, 0xc002858ff0, {0xc00285c860, 0x2, 0x2}}, {0xf387580?, 0xc003764cc0?}, 0xc003d09810)
    github.com/hashicorp/terraform-plugin-mux@v0.11.1/tf5muxserver/mux_server_ApplyResourceChange.go:30 +0x139
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc002848d20, {0xf387580?, 0xc0037644b0?}, 0xc0013e6d90)
    github.com/hashicorp/terraform-plugin-go@v0.18.0/tfprotov5/tf5server/server.go:821 +0x574
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xdd4fb40?, 0xc002848d20}, {0xf387580, 0xc0037644b0}, 0xc0013e6d20, 0x0)
    github.com/hashicorp/terraform-plugin-go@v0.18.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:422 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000910000, {0xf3943a0, 0xc00292a820}, 0xc001bba900, 0xc002914e10, 0x162634e0, 0x0)
    google.golang.org/grpc@v1.56.1/server.go:1337 +0xdf3
google.golang.org/grpc.(*Server).handleStream(0xc000910000, {0xf3943a0, 0xc00292a820}, 0xc001bba900, 0x0)
    google.golang.org/grpc@v1.56.1/server.go:1714 +0xa36
google.golang.org/grpc.(*Server).serveStreams.func1.1()
    google.golang.org/grpc@v1.56.1/server.go:959 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
    google.golang.org/grpc@v1.56.1/server.go:957 +0x18c

Error: The terraform-provider-aws_v5.8.0_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

resource "aws_ec2_traffic_mirror_filter_rule" "rule" {
  for_each                 = {
    for key, value in {
      all_in  = { description = "ALL IN",  direction = "ingress" },
      all_out = { description = "ALL OUT", direction = "egress"  },
    } : key => value
  }
  description              = each.value.description
  traffic_mirror_filter_id = aws_ec2_traffic_mirror_filter.filter.id
  destination_cidr_block   = "0.0.0.0/0"
  source_cidr_block        = "0.0.0.0/0"
  rule_number              = 1
  rule_action              = "accept"
  traffic_direction        = each.value.direction
  protocol                 = 0
}

Steps to Reproduce

1) Create traffic mirror resource "aws_ec2_traffic_mirror_filter" "filter" 2) Create resource "aws_ec2_traffic_mirror_filter_rule" "rule" with igress/egress rules 3) Create resource "aws_ec2_traffic_mirror_target" "target" 4) Create resource "aws_ec2_traffic_mirror_session" "session" 5) Change rule_number to another number (look point 2 - aws_ec2_traffic_mirror_filter_rule) 6) terraform apply

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

ewbankkit commented 1 year ago

https://github.com/hashicorp/terraform-provider-aws/blob/71ac1fa8dd1c0aea46877437921d7443edbe0aa7/internal/service/ec2/vpc_traffic_mirror_filter_rule.go#L258-L260

rule_action should be rule_number.

ewbankkit commented 1 year ago

I can reproduce this with an updated acceptance test case:

% make testacc TESTARGS='-run=TestAccVPCTrafficMirrorFilterRule_basic' PKG=ec2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20  -run=TestAccVPCTrafficMirrorFilterRule_basic -timeout 180m
=== RUN   TestAccVPCTrafficMirrorFilterRule_basic
=== PAUSE TestAccVPCTrafficMirrorFilterRule_basic
=== CONT  TestAccVPCTrafficMirrorFilterRule_basic
panic: interface conversion: interface {} is string, not int

goroutine 17226 [running]:
github.com/hashicorp/terraform-provider-aws/internal/service/ec2.resourceTrafficMirrorFilterRuleUpdate({0x105a6280, 0xc0045e1620}, 0xc005e13e00, {0xf163540?, 0xc0040a0dd0?})
    /Users/ewbankkit/altsrc.2/github.com/terraform-providers/terraform-provider-aws/internal/service/ec2/vpc_traffic_mirror_filter_rule.go:259 +0x1134
github.com/hashicorp/terraform-provider-aws/internal/provider.interceptedHandler[...].func1(0x0?, {0xf163540?, 0xc0040a0dd0?})
    /Users/ewbankkit/altsrc.2/github.com/terraform-providers/terraform-provider-aws/internal/provider/intercept.go:111 +0x34b
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0x105a6280?, {0x105a6280?, 0xc0045c9fb0?}, 0xd?, {0xf163540?, 0xc0040a0dd0?})
    /Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.27.0/helper/schema/resource.go:762 +0x87
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc001fb7880, {0x105a6280, 0xc0045c9fb0}, 0xc002763d40, 0xc005e13c80, {0xf163540, 0xc0040a0dd0})
    /Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.27.0/helper/schema/resource.go:874 +0x845
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0042656b0, {0x105a6280?, 0xc0045c9ef0?}, 0xc0026d7ae0)
    /Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.27.0/helper/schema/grpc_provider.go:1024 +0xe8d
github.com/hashicorp/terraform-plugin-mux/tf5muxserver.muxServer.ApplyResourceChange({0xc00067a510, 0xc0042407e0, 0xc00067a540, 0xc00067a570, {0xc0040aa440, 0x2, 0x2}}, {0x105a6280?, 0xc0045c9c20?}, 0xc0026d7ae0)
    /Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-mux@v0.11.2/tf5muxserver/mux_server_ApplyResourceChange.go:30 +0x139
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc0040794a0, {0x105a6280?, 0xc0045c9350?}, 0xc000c700e0)
    /Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.18.0/tfprotov5/tf5server/server.go:821 +0x574
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xee3b780?, 0xc0040794a0}, {0x105a6280, 0xc0045c9350}, 0xc000c70070, 0x0)
    /Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.18.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:422 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc004c54b40, {0x105b3380, 0xc005716b60}, 0xc0029977a0, 0xc00067ad80, 0x176f5cc0, 0x0)
    /Users/ewbankkit/go/pkg/mod/google.golang.org/grpc@v1.56.1/server.go:1337 +0xdf3
google.golang.org/grpc.(*Server).handleStream(0xc004c54b40, {0x105b3380, 0xc005716b60}, 0xc0029977a0, 0x0)
    /Users/ewbankkit/go/pkg/mod/google.golang.org/grpc@v1.56.1/server.go:1714 +0xa36
google.golang.org/grpc.(*Server).serveStreams.func1.1()
    /Users/ewbankkit/go/pkg/mod/google.golang.org/grpc@v1.56.1/server.go:959 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
    /Users/ewbankkit/go/pkg/mod/google.golang.org/grpc@v1.56.1/server.go:957 +0x18c
FAIL    github.com/hashicorp/terraform-provider-aws/internal/service/ec2    52.585s
FAIL
make: *** [testacc] Error 1
github-actions[bot] commented 11 months ago

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.