-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Panic occurs when refreshing the state of aws_ec2_traffic_mirror_filter_rule
resource
#22312
Comments
terraform-provider-aws/internal/service/ec2/traffic_mirror_filter_rule.go Lines 191 to 193 in 12e7ebf
terraform-provider-aws/internal/service/ec2/traffic_mirror_filter_rule.go Lines 354 to 366 in 12e7ebf
I think that |
This seems to be a bug of mapstructure. https://go.dev/play/p/BMxes5mbumY
You can fix the problem by changing the type from array to slice. https://go.dev/play/p/xrfz5X8RJis I have created a draft pull request. #22315 |
I've reported the issue to mapstructure. |
I can't understand why this problem can't be reproduced by the acceptance test. 🤔 terraform-provider-aws/internal/service/ec2/traffic_mirror_filter_rule_test.go Lines 61 to 80 in 386807b
|
We are getting a crash in the HashiCorp nightly CI:
and I can reproduce locally: % make testacc PKG=ec2 TESTS=TestAccEC2TrafficMirrorFilterRule_basic
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccEC2TrafficMirrorFilterRule_basic' -timeout 180m
=== RUN TestAccEC2TrafficMirrorFilterRule_basic
=== PAUSE TestAccEC2TrafficMirrorFilterRule_basic
=== CONT TestAccEC2TrafficMirrorFilterRule_basic
panic: reflect: call of reflect.Value.IsNil on array Value
goroutine 1075 [running]:
reflect.Value.IsNil(...)
/usr/local/Cellar/go/1.16.3/libexec/src/reflect/value.go:1086
github.com/mitchellh/mapstructure.(*Decoder).decodeSlice(0xc001deb090, 0x0, 0x0, 0x849ffa0, 0xc00231f8d0, 0x82d6260, 0xc001b24870, 0x197, 0x8, 0x8)
/Users/ewbankkit/go/pkg/mod/github.com/mitchellh/mapstructure@v1.4.2/mapstructure.go:1095 +0x10ad
github.com/mitchellh/mapstructure.(*Decoder).decode(0xc001deb090, 0x0, 0x0, 0x849ffa0, 0xc00231f8d0, 0x82d6260, 0xc001b24870, 0x197, 0xc001b24870, 0x197)
/Users/ewbankkit/go/pkg/mod/github.com/mitchellh/mapstructure@v1.4.2/mapstructure.go:469 +0x836
github.com/mitchellh/mapstructure.(*Decoder).Decode(0xc001deb090, 0x849ffa0, 0xc00231f8d0, 0x0, 0xc001b24870)
/Users/ewbankkit/go/pkg/mod/github.com/mitchellh/mapstructure@v1.4.2/mapstructure.go:398 +0xf0
github.com/mitchellh/mapstructure.Decode(0x849ffa0, 0xc00231f8d0, 0x823c820, 0xc001b24870, 0x1, 0xa3f98aa)
/Users/ewbankkit/go/pkg/mod/github.com/mitchellh/mapstructure@v1.4.2/mapstructure.go:302 +0xa5
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*MapFieldWriter).setList(0xc001b241c8, 0xc00231f8e0, 0x1, 0x1, 0x849ffa0, 0xc00231f8d0, 0xc000bc6640, 0xa3f98aa, 0xc002344000)
/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/field_writer_map.go:127 +0xd2
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*MapFieldWriter).set(0xc001b241c8, 0xc00231f8e0, 0x1, 0x1, 0x849ffa0, 0xc00231f8d0, 0x1, 0x1)
/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/field_writer_map.go:103 +0xde
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*MapFieldWriter).WriteField(0xc001b241c8, 0xc00231f8e0, 0x1, 0x1, 0x849ffa0, 0xc00231f8d0, 0x0, 0x0)
/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/field_writer_map.go:89 +0x3f9
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*ResourceData).Set(0xc00264a400, 0xa3f98aa, 0x16, 0x849ffa0, 0xc00231f8d0, 0x0, 0x0)
/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/resource_data.go:227 +0x1df
github.com/hashicorp/terraform-provider-aws/internal/service/ec2.resourceTrafficMirrorFilterRuleRead(0xc00264a400, 0x9082c20, 0xc000578000, 0x0, 0x0)
/Users/ewbankkit/altsrc.1/github.com/terraform-providers/terraform-provider-aws/internal/service/ec2/traffic_mirror_filter_rule.go:191 +0x5dd
github.com/hashicorp/terraform-provider-aws/internal/service/ec2.resourceTrafficMirrorFilterRuleUpdate(0xc00264a400, 0x9082c20, 0xc000578000, 0x0, 0xffffffffffffffff)
/Users/ewbankkit/altsrc.1/github.com/terraform-providers/terraform-provider-aws/internal/service/ec2/traffic_mirror_filter_rule.go:318 +0x4da
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0xc000bc0d20, 0xb3e16d8, 0xc0020616c0, 0xc00264a400, 0x9082c20, 0xc000578000, 0x0, 0x0, 0x0)
/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/resource.go:363 +0x1ee
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc000bc0d20, 0xb3e16d8, 0xc0020616c0, 0xc0027cbc70, 0xc00264a280, 0x9082c20, 0xc000578000, 0x0, 0x0, 0x0, ...)
/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/resource.go:475 +0x390
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0013469a8, 0xb3e16d8, 0xc0020616c0, 0xc0022c1a40, 0xa3cb0a8, 0x12, 0x0)
/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/grpc_provider.go:977 +0xacf
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc002e30280, 0xb3e1780, 0xc0020616c0, 0xc0022da460, 0x0, 0x0, 0x0)
/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:603 +0x465
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0xa12ed80, 0xc002e30280, 0xb3e1780, 0xc0022ecf00, 0xc0027c2ae0, 0x0, 0xb3e1780, 0xc0022ecf00, 0xc0022f4000, 0x478)
/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:380 +0x214
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00130b500, 0xb40f078, 0xc00260d800, 0xc00012f900, 0xc002e7f380, 0x1006a980, 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(0xc00130b500, 0xb40f078, 0xc00260d800, 0xc00012f900, 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(0xc001708f40, 0xc00130b500, 0xb40f078, 0xc00260d800, 0xc00012f900)
/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
FAIL github.com/hashicorp/terraform-provider-aws/internal/service/ec2 22.719s
FAIL
make: *** [testacc] Error 1 |
Oh, I see. Thank you. |
I could reproduce the issue on the main branch. $ make testacc TESTS=TestAccEC2TrafficMirrorFilterRule PKG=ec2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccEC2TrafficMirrorFilterRule' -timeout 180m
=== RUN TestAccEC2TrafficMirrorFilterRule_basic
=== PAUSE TestAccEC2TrafficMirrorFilterRule_basic
=== RUN TestAccEC2TrafficMirrorFilterRule_disappears
=== PAUSE TestAccEC2TrafficMirrorFilterRule_disappears
=== CONT TestAccEC2TrafficMirrorFilterRule_basic
=== CONT TestAccEC2TrafficMirrorFilterRule_disappears
--- PASS: TestAccEC2TrafficMirrorFilterRule_disappears (54.68s)
panic: reflect: call of reflect.Value.IsNil on array Value
goroutine 1859 [running]:
reflect.Value.IsNil(...)
/usr/local/Cellar/go/1.17.5/libexec/src/reflect/value.go:1427
github.com/mitchellh/mapstructure.(*Decoder).decodeSlice(0xc003ac90d8, {0x0, 0x0}, {0x73de360, 0xc0024450e0}, {0x722c260, 0xc0017f82e8, 0x203000})
/Users/shunsuke-suzuki/go/pkg/mod/github.com/mitchellh/mapstructure@v1.4.2/mapstructure.go:1095 +0xbfe
github.com/mitchellh/mapstructure.(*Decoder).decode(0xc003ac90d8, {0x0, 0xc00242d901}, {0x73de360, 0xc0024450e0}, {0x722c260, 0xc0017f82e8, 0x48})
/Users/shunsuke-suzuki/go/pkg/mod/github.com/mitchellh/mapstructure@v1.4.2/mapstructure.go:469 +0x3ff
github.com/mitchellh/mapstructure.(*Decoder).Decode(0xc003ac90d8, {0x73de360, 0xc0024450e0})
/Users/shunsuke-suzuki/go/pkg/mod/github.com/mitchellh/mapstructure@v1.4.2/mapstructure.go:398 +0xd8
github.com/mitchellh/mapstructure.Decode({0x73de360, 0xc0024450e0}, {0x719fc40, 0xc0017f82e8})
/Users/shunsuke-suzuki/go/pkg/mod/github.com/mitchellh/mapstructure@v1.4.2/mapstructure.go:302 +0x91
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*MapFieldWriter).setList(0xc002b2f500, {0xc0024450f0, 0x1, 0x1}, {0x73de360, 0xc0024450e0}, 0x92c8f90)
/Users/shunsuke-suzuki/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/field_writer_map.go:127 +0xba
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*MapFieldWriter).set(0xc002b2f500, {0xc0024450f0, 0x1, 0x1}, {0x73de360, 0xc0024450e0})
/Users/shunsuke-suzuki/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/field_writer_map.go:103 +0xa5
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*MapFieldWriter).WriteField(0xc002b2f500, {0xc0024450f0, 0x1, 0x1}, {0x73de360, 0xc0024450e0})
/Users/shunsuke-suzuki/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/field_writer_map.go:89 +0x3f9
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*ResourceData).Set(0xc002926680, {0x92c8f90, 0x16}, {0x73de360, 0xc0024450e0})
/Users/shunsuke-suzuki/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/resource_data.go:227 +0x21c
github.com/hashicorp/terraform-provider-aws/internal/service/ec2.resourceTrafficMirrorFilterRuleRead(0xc002926680, {0x7fa95c0, 0xc000943500})
/Users/shunsuke-suzuki/repos/src/github.com/suzuki-shunsuke/terraform-provider-aws/internal/service/ec2/traffic_mirror_filter_rule.go:191 +0x5c5
github.com/hashicorp/terraform-provider-aws/internal/service/ec2.resourceTrafficMirrorFilterRuleUpdate(0xc002926680, {0x7fa95c0, 0xc000943500})
/Users/shunsuke-suzuki/repos/src/github.com/suzuki-shunsuke/terraform-provider-aws/internal/service/ec2/traffic_mirror_filter_rule.go:318 +0xfc5
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0x7d07780, {0xa2196d8, 0xc002098e80}, 0x24, {0x7fa95c0, 0xc000943500})
/Users/shunsuke-suzuki/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/resource.go:363 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0007bce00, {0xa2196d8, 0xc002098e80}, 0xc00237b520, 0xc002926500, {0x7fa95c0, 0xc000943500})
/Users/shunsuke-suzuki/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/resource.go:475 +0x6ba
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0015f24e0, {0xa2196d8, 0xc002098e80}, 0xc00222b3b0)
/Users/shunsuke-suzuki/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/grpc_provider.go:977 +0xd8a
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc0020ae280, {0xa219780, 0xc00223b860}, 0xc002228380)
/Users/shunsuke-suzuki/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:603 +0x30e
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x9016380, 0xc0020ae280}, {0xa219780, 0xc00223b860}, 0xc002274a80, 0x0)
/Users/shunsuke-suzuki/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:380 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0009b9500, {0xa30b0e8, 0xc001618180}, 0xc002c51f00, 0xc002096d20, 0xf7b8ee0, 0x0)
/Users/shunsuke-suzuki/go/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:1194 +0xc8f
google.golang.org/grpc.(*Server).handleStream(0xc0009b9500, {0xa30b0e8, 0xc001618180}, 0xc002c51f00, 0x0)
/Users/shunsuke-suzuki/go/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:1517 +0xa2a
google.golang.org/grpc.(*Server).serveStreams.func1.2()
/Users/shunsuke-suzuki/go/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:859 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
/Users/shunsuke-suzuki/go/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:857 +0x294
FAIL github.com/hashicorp/terraform-provider-aws/internal/service/ec2 67.255s
FAIL
make: *** [testacc] Error 1 |
This functionality has been released in v3.71.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. Thank you! |
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. |
Community Note
Terraform CLI and Terraform AWS Provider Version
Affected Resource(s)
Terraform Configuration Files
Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.
It seems to occur panic when refleshing the state.
Therefore, only the settings related to
aws_ec2_traffic_mirror_filter_rule
are described in this issue.Debug Output
https://gist.github.com/44smkn/c0ff8bddab345a1e354fe06510686b8a
Panic Output
Expected Behavior
The terraform plan completes normally without panic.
Actual Behavior
The panic occurred when running terraform plan.
Steps to Reproduce
terraform plan
Important Factoids
References
The text was updated successfully, but these errors were encountered: