Skip to content
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

Closed
44smkn opened this issue Dec 22, 2021 · 9 comments · Fixed by #22315
Closed

Panic occurs when refreshing the state of aws_ec2_traffic_mirror_filter_rule resource #22312

44smkn opened this issue Dec 22, 2021 · 9 comments · Fixed by #22315
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/ec2 Issues and PRs that pertain to the ec2 service.
Milestone

Comments

@44smkn
Copy link

44smkn commented Dec 22, 2021

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.1.2
  • terraform-provider-aws: v3.69.0 and v3.70.0
    • I tried with v3.70.0, but it was also failed.

Affected Resource(s)

  • aws_ec2_traffic_mirror_filter_rule

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.

resource "aws_ec2_traffic_mirror_filter" "arkime" {
  description = "arkime"

  tags = {
    Name  = "arkime-staging"
  }
}

resource "aws_ec2_traffic_mirror_filter_rule" "inbound" {
  description              = "only TCP"
  traffic_mirror_filter_id = aws_ec2_traffic_mirror_filter.arkime.id
  destination_cidr_block   = "0.0.0.0/0"
  source_cidr_block        = "0.0.0.0/0"
  destination_port_range {
    from_port = 443
    to_port   = 443
  }
  protocol          = 6
  rule_action       = "accept"
  rule_number       = 1
  traffic_direction = "ingress"
}

Debug Output

https://gist.github.com/44smkn/c0ff8bddab345a1e354fe06510686b8a

Panic Output

Stack trace from the terraform-provider-aws_v3.69.0_x5 plugin:

panic: reflect: call of reflect.Value.IsNil on array Value

goroutine 341 [running]:
reflect.Value.IsNil(...)
    /opt/goenv/versions/1.16.0/src/reflect/value.go:1086
github.com/mitchellh/mapstructure.(*Decoder).decodeSlice(0xc00012d8c8, 0x0, 0x0, 0x751ba60, 0xc001719d50, 0x7356c80, 0xc001692240, 0x197, 0x8, 0x8)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/mitchellh/mapstructure@v1.4.2/mapstructure.go:1095 +0x10ad
github.com/mitchellh/mapstructure.(*Decoder).decode(0xc00012d8c8, 0x0, 0x0, 0x751ba60, 0xc001719d50, 0x7356c80, 0xc001692240, 0x197, 0xc001692240, 0x197)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/mitchellh/mapstructure@v1.4.2/mapstructure.go:469 +0x836
github.com/mitchellh/mapstructure.(*Decoder).Decode(0xc00012d8c8, 0x751ba60, 0xc001719d50, 0x0, 0xc001692240)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/mitchellh/mapstructure@v1.4.2/mapstructure.go:398 +0xf0
github.com/mitchellh/mapstructure.Decode(0x751ba60, 0xc001719d50, 0x72be320, 0xc001692240, 0x1, 0x943db75)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/mitchellh/mapstructure@v1.4.2/mapstructure.go:302 +0xa5
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*MapFieldWriter).setList(0xc0027e1ed8, 0xc001719d60, 0x1, 0x1, 0x751ba60, 0xc001719d50, 0xc000632140, 0x943db75, 0xc001721a40)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.9.0/helper/schema/field_writer_map.go:127 +0xd2
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*MapFieldWriter).set(0xc0027e1ed8, 0xc001719d60, 0x1, 0x1, 0x751ba60, 0xc001719d50, 0x1, 0x1)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.9.0/helper/schema/field_writer_map.go:103 +0xde
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*MapFieldWriter).WriteField(0xc0027e1ed8, 0xc001719d60, 0x1, 0x1, 0x751ba60, 0xc001719d50, 0x0, 0x0)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.9.0/helper/schema/field_writer_map.go:89 +0x3f9
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*ResourceData).Set(0xc002615500, 0x943db75, 0x16, 0x751ba60, 0xc001719d50, 0x0, 0x0)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.9.0/helper/schema/resource_data.go:227 +0x1df
github.com/hashicorp/terraform-provider-aws/internal/service/ec2.resourceTrafficMirrorFilterRuleRead(0xc002615500, 0x80eb5a0, 0xc00033a000, 0xee81f80, 0xc000088800)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/hashicorp/terraform-provider-aws/internal/service/ec2/traffic_mirror_filter_rule.go:191 +0x5dd
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc0005ada40, 0xa356e48, 0xc002806d00, 0xc002615500, 0x80eb5a0, 0xc00033a000, 0x0, 0x0, 0x0)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.9.0/helper/schema/resource.go:346 +0x1ee
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0005ada40, 0xa356e48, 0xc002806d00, 0xc002619110, 0x80eb5a0, 0xc00033a000, 0xc002669700, 0x0, 0x0, 0x0)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.9.0/helper/schema/resource.go:635 +0x1cb
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc000122f30, 0xa356e48, 0xc002806d00, 0xc002806d40, 0xc002806d00, 0x40b965, 0x8d4fba0)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.9.0/helper/schema/grpc_provider.go:576 +0x47d
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc002039220, 0xa356ef0, 0xc002806d00, 0xc002803740, 0xc002039220, 0xc000a5fba0, 0x46d147)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.4.0/tfprotov5/tf5server/server.go:298 +0x105
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler(0x912f180, 0xc002039220, 0xa356ef0, 0xc002851a40, 0xc0028036e0, 0x0, 0xa356ef0, 0xc002851a40, 0xc0027fc1e0, 0x1ca)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.4.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:344 +0x214
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000cfc00, 0xa383478, 0xc002076300, 0xc002600d00, 0xc000a30ab0, 0xee3fcb0, 0x0, 0x0, 0x0)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:1194 +0x52b
google.golang.org/grpc.(*Server).handleStream(0xc0000cfc00, 0xa383478, 0xc002076300, 0xc002600d00, 0x0)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:1517 +0xd0c
google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc0018b2f10, 0xc0000cfc00, 0xa383478, 0xc002076300, 0xc002600d00)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:859 +0xab
created by google.golang.org/grpc.(*Server).serveStreams.func1
    /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:857 +0x1fd

Expected Behavior

The terraform plan completes normally without panic.

Actual Behavior

The panic occurred when running terraform plan.

Steps to Reproduce

  1. terraform plan

Important Factoids

References

  • #0000
@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/ec2 Issues and PRs that pertain to the ec2 service. labels Dec 22, 2021
@ewbankkit
Copy link
Contributor

if err := d.Set("destination_port_range", buildTrafficMirrorFilterRulePortRangeSchema(rule.DestinationPortRange)); err != nil {
return fmt.Errorf("error setting destination_port_range: %s", err)
}

func buildTrafficMirrorFilterRulePortRangeSchema(portRange *ec2.TrafficMirrorPortRange) interface{} {
if nil == portRange {
return nil
}
var out [1]interface{}
elem := make(map[string]interface{})
elem["from_port"] = portRange.FromPort
elem["to_port"] = portRange.ToPort
out[0] = elem
return out
}

I think that buildTrafficMirrorFilterRulePortRangeSchema should have a return type of []interface{}, not interface{}.

@suzuki-shunsuke
Copy link
Contributor

suzuki-shunsuke commented Dec 22, 2021

This seems to be a bug of mapstructure.
I could reproduce the problem.

https://go.dev/play/p/BMxes5mbumY

panic: reflect: call of reflect.Value.IsNil on array Value

goroutine 1 [running]:
reflect.Value.IsNil(...)
	/usr/local/go-faketime/src/reflect/value.go:1427
github.com/mitchellh/mapstructure.(*Decoder).decodeSlice(0xc000120018, {0x0, 0x0}, {0x4b4aa0, 0xc00010a4b0}, {0x4b2fa0, 0xc00011a030, 0x203000})
	/tmp/gopath2282395412/pkg/mod/github.com/mitchellh/mapstructure@v1.4.3/mapstructure.go:1091 +0xbfe
github.com/mitchellh/mapstructure.(*Decoder).decode(0xc000120018, {0x0, 0xc000126001}, {0x4b4aa0, 0xc00010a4b0}, {0x4b2fa0, 0xc00011a030, 0x48})
	/tmp/gopath2282395412/pkg/mod/github.com/mitchellh/mapstructure@v1.4.3/mapstructure.go:469 +0x3ff
github.com/mitchellh/mapstructure.(*Decoder).Decode(0xc000120018, {0x4b4aa0, 0xc00010a4b0})
	/tmp/gopath2282395412/pkg/mod/github.com/mitchellh/mapstructure@v1.4.3/mapstructure.go:398 +0xd8
github.com/mitchellh/mapstructure.Decode({0x4b4aa0, 0xc00010a4b0}, {0x4b0be0, 0xc00011a030})
	/tmp/gopath2282395412/pkg/mod/github.com/mitchellh/mapstructure@v1.4.3/mapstructure.go:302 +0x91
main.core()
	/tmp/sandbox2579048427/prog.go:19 +0x65
main.main()
	/tmp/sandbox2579048427/prog.go:11 +0x19

Program exited.

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'll do the acceptance test and investigate why this problem can't be detected by the acceptance test.

@suzuki-shunsuke
Copy link
Contributor

I've reported the issue to mapstructure.
mitchellh/mapstructure#264

@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Dec 22, 2021
@suzuki-shunsuke
Copy link
Contributor

I can't understand why this problem can't be reproduced by the acceptance test. 🤔

{
Config: testAccEc2TrafficMirrorFilterRuleConfigFull(dstCidr, srcCidr, action, direction, description, ruleNum, srcPortFrom, srcPortTo, dstPortFrom, dstPortTo, protocol),
Check: resource.ComposeTestCheckFunc(
testAccCheckTrafficMirrorFilterRuleExists(resourceName),
resource.TestMatchResourceAttr(resourceName, "traffic_mirror_filter_id", regexp.MustCompile("tmf-.*")),
resource.TestCheckResourceAttr(resourceName, "destination_cidr_block", dstCidr),
resource.TestCheckResourceAttr(resourceName, "rule_action", action),
resource.TestCheckResourceAttr(resourceName, "rule_number", strconv.Itoa(ruleNum)),
resource.TestCheckResourceAttr(resourceName, "source_cidr_block", srcCidr),
resource.TestCheckResourceAttr(resourceName, "traffic_direction", direction),
resource.TestCheckResourceAttr(resourceName, "description", description),
resource.TestCheckResourceAttr(resourceName, "destination_port_range.#", "1"),
resource.TestCheckResourceAttr(resourceName, "destination_port_range.0.from_port", strconv.Itoa(dstPortFrom)),
resource.TestCheckResourceAttr(resourceName, "destination_port_range.0.to_port", strconv.Itoa(dstPortTo)),
resource.TestCheckResourceAttr(resourceName, "source_port_range.#", "1"),
resource.TestCheckResourceAttr(resourceName, "source_port_range.0.from_port", strconv.Itoa(srcPortFrom)),
resource.TestCheckResourceAttr(resourceName, "source_port_range.0.to_port", strconv.Itoa(srcPortTo)),
resource.TestCheckResourceAttr(resourceName, "protocol", strconv.Itoa(protocol)),
),
},

@ewbankkit
Copy link
Contributor

ewbankkit commented Dec 22, 2021

We are getting a crash in the HashiCorp nightly CI:

est ended in panic.
------- Stdout: -------
=== RUN   TestAccEC2TrafficMirrorFilterRule_basic
=== PAUSE TestAccEC2TrafficMirrorFilterRule_basic
=== CONT  TestAccEC2TrafficMirrorFilterRule_basic
------- Stderr: -------
panic: reflect: call of reflect.Value.IsNil on array Value
goroutine 1098 [running]:
reflect.Value.IsNil(...)
  /opt/goenv/versions/1.16.0/src/reflect/value.go:1086
github.com/mitchellh/mapstructure.(*Decoder).decodeSlice(0xc0033f7448, 0x0, 0x0, 0x78545a0, 0xc003128a40, 0x768d020, 0xc000c983a8, 0x197, 0x8, 0x8)
  /var/lib/teamcity/go/pkg/mod/github.com/mitchellh/mapstructure@v1.4.2/mapstructure.go:1095 +0x10ad
github.com/mitchellh/mapstructure.(*Decoder).decode(0xc0033f7448, 0x0, 0x0, 0x78545a0, 0xc003128a40, 0x768d020, 0xc000c983a8, 0x197, 0xc000c983a8, 0x197)
  /var/lib/teamcity/go/pkg/mod/github.com/mitchellh/mapstructure@v1.4.2/mapstructure.go:469 +0x836
github.com/mitchellh/mapstructure.(*Decoder).Decode(0xc0033f7448, 0x78545a0, 0xc003128a40, 0x0, 0xc000c983a8)
  /var/lib/teamcity/go/pkg/mod/github.com/mitchellh/mapstructure@v1.4.2/mapstructure.go:398 +0xf0
github.com/mitchellh/mapstructure.Decode(0x78545a0, 0xc003128a40, 0x75f3c40, 0xc000c983a8, 0x1, 0x97910dd)
  /var/lib/teamcity/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(0xc001eb5a28, 0xc003128a50, 0x1, 0x1, 0x78545a0, 0xc003128a40, 0xc000a26780, 0x97910dd, 0xc0011e7cc0)
  /var/lib/teamcity/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(0xc001eb5a28, 0xc003128a50, 0x1, 0x1, 0x78545a0, 0xc003128a40, 0x1, 0x1)
  /var/lib/teamcity/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(0xc001eb5a28, 0xc003128a50, 0x1, 0x1, 0x78545a0, 0xc003128a40, 0x0, 0x0)
  /var/lib/teamcity/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(0xc001e0b700, 0x97910dd, 0x16, 0x78545a0, 0xc003128a40, 0x0, 0x0)
  /var/lib/teamcity/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(0xc001e0b700, 0x842bc60, 0xc001c14900, 0x0, 0x0)
  /opt/teamcity-agent/work/87cd0779df5e20c9/internal/service/ec2/traffic_mirror_filter_rule.go:191 +0x5dd
github.com/hashicorp/terraform-provider-aws/internal/service/ec2.resourceTrafficMirrorFilterRuleUpdate(0xc001e0b700, 0x842bc60, 0xc001c14900, 0x0, 0xffffffffffffffff)
  /opt/teamcity-agent/work/87cd0779df5e20c9/internal/service/ec2/traffic_mirror_filter_rule.go:318 +0x4da
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0xc000a229a0, 0xa76a3f8, 0xc0038fdfc0, 0xc001e0b700, 0x842bc60, 0xc001c14900, 0x0, 0x0, 0x0)
  /var/lib/teamcity/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(0xc000a229a0, 0xa76a3f8, 0xc0038fdfc0, 0xc0018a3380, 0xc001e0b580, 0x842bc60, 0xc001c14900, 0x0, 0x0, 0x0, ...)
  /var/lib/teamcity/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(0xc002900528, 0xa76a3f8, 0xc0038fdfc0, 0xc00123af50, 0x9762af9, 0x12, 0x0)
  /var/lib/teamcity/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(0xc001da6280, 0xa76a4a0, 0xc0038fdfc0, 0xc0024fec40, 0x0, 0x0, 0x0)
  /var/lib/teamcity/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(0x94c78c0, 0xc001da6280, 0xa76a4a0, 0xc0004ddb90, 0xc001fc3020, 0x0, 0xa76a4a0, 0xc0004ddb90, 0xc0026f8480, 0x478)
  /var/lib/teamcity/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(0xc001cd6000, 0xa7979d8, 0xc001a0b980, 0xc00029e400, 0xc0024f0c90, 0xf39d800, 0x0, 0x0, 0x0)
  /var/lib/teamcity/go/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:1194 +0x52b
google.golang.org/grpc.(*Server).handleStream(0xc001cd6000, 0xa7979d8, 0xc001a0b980, 0xc00029e400, 0x0)
  /var/lib/teamcity/go/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:1517 +0xd0c
google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc001040030, 0xc001cd6000, 0xa7979d8, 0xc001a0b980, 0xc00029e400)
  /var/lib/teamcity/go/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:859 +0xab
created by google.golang.org/grpc.(*Server).serveStreams.func1
  /var/lib/teamcity/go/pkg/mod/google.golang.org/grpc@v1.32.0/server.go:857 +0x1fd

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

@suzuki-shunsuke
Copy link
Contributor

suzuki-shunsuke commented Dec 22, 2021

Oh, I see. Thank you.
I've confirmed the acceptance test has been passed.
#22315 (comment)

@suzuki-shunsuke
Copy link
Contributor

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

@github-actions github-actions bot added this to the v3.71.0 milestone Dec 22, 2021
@github-actions
Copy link

github-actions bot commented Jan 6, 2022

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!

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants