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

resource/aws_ec2_managed_prefix_list: The plugin encountered an error, and failed to respond to the #19421

Closed
tcharewicz opened this issue May 18, 2021 · 4 comments · Fixed by #19517
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/ec2 Issues and PRs that pertain to the ec2 service.
Milestone

Comments

@tcharewicz
Copy link

tcharewicz commented May 18, 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 -v
Terraform v0.15.3
on darwin_amd64

  • provider registry.terraform.io/hashicorp/aws v3.40.0

Affected Resource(s)

  • aws_ec2_managed_prefix_list

Terraform Configuration Files

None.

Debug Output

None.

Panic Output

https://gist.github.com/tcharewicz/309944f89409bcff10cbeada57db0331

Expected Behavior

Terraform should modify resouce, add or delete description.

  # aws_ec2_managed_prefix_list.this will be updated in-place
  ~ resource "aws_ec2_managed_prefix_list" "this" {
        id             = "pl-0f8022f4f29018d7a"
        name           = "this"
        tags           = {
            "ResourceOwner" = "test"
        }
      ~ version        = 1 -> (known after apply)
        # (5 unchanged attributes hidden)

      + entry {
          + cidr = "1.1.1.0/24"
        }
      - entry {
          - cidr        = "1.1.1.0/24" -> null
          - description = "this" -> null
        }
      + entry {
          + cidr = "1.1.2.0/24"
        }
      - entry {
          - cidr        = "1.1.2.0/24" -> null
          - description = "this" -> null
        }
      + entry {
          + cidr = "1.1.3.0/24"
        }
      - entry {
          - cidr        = "1.1.3.0/24" -> null
          - description = "this" -> null
        }
      + entry {
          + cidr = "1.1.4.0/24"
        }
      - entry {
          - cidr        = "1.1.4.0/24" -> null
          - description = "this" -> null
        }
      + entry {
          + cidr = "1.1.5.0/24"
        }
      - entry {
          - cidr        = "1.1.5.0/24" -> null
          - description = "this" -> null
        }
    }

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

Actual Behavior

Terraform crashed.

Steps to Reproduce

  1. Create manged prefix list, with 5 entries. All entries has descriptions.
provider "aws" {
  region = "eu-central-1"
}

resource "aws_ec2_managed_prefix_list" "this" {
  name           = "this"
  address_family = "IPv4"
  max_entries    = 5

  entry {
    cidr = "1.1.1.0/24"
    description = "this"
  }

  entry {
    cidr = "1.1.2.0/24"
    description = "this"
  }

  entry {
    cidr = "1.1.3.0/24"
    description = "this"
  }

  entry {
    cidr = "1.1.4.0/24"
    description = "this"
  }

  entry {
    cidr = "1.1.5.0/24"
    description = "this"
  }

  tags = {
      "ResourceOwner"      = "test"
  }
}
  1. Applay configuration
terraform init
terraform apply
  1. Comment descriptions at entries level.
provider "aws" {
  region = "eu-central-1"
}

resource "aws_ec2_managed_prefix_list" "this" {
  name           = "this"
  address_family = "IPv4"
  max_entries    = 5

  entry {
    cidr = "1.1.1.0/24"
    # description = "this"
  }

  entry {
    cidr = "1.1.2.0/24"
    # description = "this"
  }

  entry {
    cidr = "1.1.3.0/24"
    # description = "this"
  }

  entry {
    cidr = "1.1.4.0/24"
    # description = "this"
  }

  entry {
    cidr = "1.1.5.0/24"
    # description = "this"
  }

  tags = {
      "ResourceOwner"      = "test"
  }
}
  1. Apply
terraform apply

Important Factoids

None.

References

Three weeks ago there were a PR, that changed Behavior of that resource.

#19095

The same behavior you can observe at TF version 0.12.31 and 0.14.11. I do not make a test with TF 0.13.

@ghost ghost added the service/ec2 Issues and PRs that pertain to the ec2 service. label May 18, 2021
@ewbankkit ewbankkit added bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. labels May 18, 2021
@ewbankkit
Copy link
Contributor

ewbankkit commented May 18, 2021

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

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

goroutine 29 [running]:
github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsEc2ManagedPrefixListUpdate(0xc00152ea80, 0x6bb50a0, 0xc00134c000, 0x1, 0xffffffffffffffff)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/hashicorp/terraform-provider-aws/aws/resource_aws_ec2_managed_prefix_list.go:253 +0x1e4a
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0xc0009d6d20, 0x8417b08, 0xc001506180, 0xc00152ea80, 0x6bb50a0, 0xc00134c000, 0x0, 0x0, 0x0)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:352 +0x1ee
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0009d6d20, 0x8417b08, 0xc001506180, 0xc0001c6230, 0xc001117b20, 0x6bb50a0, 0xc00134c000, 0x0, 0x0, 0x0, ...)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:464 +0x390
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc00000c420, 0x8417b08, 0xc001506180, 0xc001508370, 0xc001506180, 0x771fee0, 0xc001500100)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:955 +0x8ef
github.com/hashicorp/terraform-plugin-go/tfprotov5/server.(*server).ApplyResourceChange(0xc001e1ed20, 0x8417bb0, 0xc001506180, 0xc0001c6070, 0xc001e1ed20, 0xc0015001b0, 0xc001524ba0)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/[email protected]/tfprotov5/server/server.go:332 +0xb5
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x771fee0, 0xc001e1ed20, 0x8417bb0, 0xc0015001b0, 0xc001878120, 0x0, 0x8417bb0, 0xc0015001b0, 0xc00151e900, 0x46e)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:380 +0x214
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00029d500, 0x8438658, 0xc001e3e900, 0xc001512000, 0xc000eeb530, 0xb9c1180, 0x0, 0x0, 0x0)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/[email protected]/server.go:1194 +0x52b
google.golang.org/grpc.(*Server).handleStream(0xc00029d500, 0x8438658, 0xc001e3e900, 0xc001512000, 0x0)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/[email protected]/server.go:1517 +0xd0c
google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc0005c09a0, 0xc00029d500, 0x8438658, 0xc001e3e900, 0xc001512000)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/[email protected]/server.go:859 +0xab
created by google.golang.org/grpc.(*Server).serveStreams.func1
        /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/[email protected]/server.go:857 +0x1fd

Relevant code:

for idx, removeEntry := range input.RemoveEntries {
for _, addEntry := range input.AddEntries {
if aws.StringValue(addEntry.Cidr) == aws.StringValue(removeEntry.Cidr) {
removalInput.RemoveEntries = append(removalInput.RemoveEntries, input.RemoveEntries[idx])
input.RemoveEntries = append(input.RemoveEntries[:idx], input.RemoveEntries[idx+1:]...)
}
}
}

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. and removed crash Results from or addresses a Terraform crash or kernel panic. bug Addresses a defect in current functionality. labels May 18, 2021
@ewbankkit ewbankkit added bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. and removed needs-triage Waiting for first response or review from a maintainer. labels May 18, 2021
@ewbankkit
Copy link
Contributor

I can reproduce this with a slightly modified acceptance test:

% make testacc TEST=./aws TESTARGS='-run=TestAccAwsEc2ManagedPrefixList_Entry_Description'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAwsEc2ManagedPrefixList_Entry_Description -timeout 180m
=== RUN   TestAccAwsEc2ManagedPrefixList_Entry_Description
=== PAUSE TestAccAwsEc2ManagedPrefixList_Entry_Description
=== CONT  TestAccAwsEc2ManagedPrefixList_Entry_Description
panic: runtime error: index out of range [1] with length 1

goroutine 1081 [running]:
github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsEc2ManagedPrefixListUpdate(0xc0021f6680, 0x8047f40, 0xc002b52000, 0x0, 0xffffffffffffffff)
	/Users/ewbankkit/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_ec2_managed_prefix_list.go:253 +0x1e4a
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0xc0016a4620, 0x9f182a8, 0xc0020e65c0, 0xc0021f6680, 0x8047f40, 0xc002b52000, 0x0, 0x0, 0x0)
	/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:352 +0x1ee
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0016a4620, 0x9f182a8, 0xc0020e65c0, 0xc002292690, 0xc00416a9c0, 0x8047f40, 0xc002b52000, 0xc003162130, 0x7e5a8a0, 0xc0022c0c00, ...)
	/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:464 +0x390
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc003c26b70, 0x9f182a8, 0xc0020e65c0, 0xc00239f900, 0xc0020e65c0, 0x8c51dc0, 0xc0022ade00)
	/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:955 +0x8ef
github.com/hashicorp/terraform-plugin-go/tfprotov5/server.(*server).ApplyResourceChange(0xc002760260, 0x9f18350, 0xc0020e65c0, 0xc0022925b0, 0xc002760260, 0xc0022ade90, 0xc003cccba0)
	/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/[email protected]/tfprotov5/server/server.go:332 +0xb5
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x8c51dc0, 0xc002760260, 0x9f18350, 0xc0022ade90, 0xc002ee8480, 0x0, 0x9f18350, 0xc0022ade90, 0xc003ca8800, 0x381)
	/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:380 +0x214
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0038eafc0, 0x9f42498, 0xc0048c3680, 0xc0021f2500, 0xc001d92540, 0xdca9c60, 0x0, 0x0, 0x0)
	/Users/ewbankkit/go/pkg/mod/google.golang.org/[email protected]/server.go:1194 +0x52b
google.golang.org/grpc.(*Server).handleStream(0xc0038eafc0, 0x9f42498, 0xc0048c3680, 0xc0021f2500, 0x0)
	/Users/ewbankkit/go/pkg/mod/google.golang.org/[email protected]/server.go:1517 +0xd0c
google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc000d00600, 0xc0038eafc0, 0x9f42498, 0xc0048c3680, 0xc0021f2500)
	/Users/ewbankkit/go/pkg/mod/google.golang.org/[email protected]/server.go:859 +0xab
created by google.golang.org/grpc.(*Server).serveStreams.func1
	/Users/ewbankkit/go/pkg/mod/google.golang.org/[email protected]/server.go:857 +0x1fd
FAIL	github.com/terraform-providers/terraform-provider-aws/aws	20.161s
FAIL
make: *** [testacc] Error 1

@ewbankkit ewbankkit added the regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. label May 25, 2021
@github-actions github-actions bot added this to the v3.43.0 milestone May 26, 2021
@ghost
Copy link

ghost commented Jun 1, 2021

This has been released in version 3.43.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 for triage. Thanks!

@github-actions
Copy link

github-actions bot commented Jul 2, 2021

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 Jul 2, 2021
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. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
2 participants