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

[Bug]: "panic interfacs convertion" when trying to create a aws_resourcegroups_resource resource #31843

Closed
ltshb opened this issue Jun 8, 2023 · 4 comments · Fixed by #30242
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/resourcegroups Issues and PRs that pertain to the resourcegroups service.

Comments

@ltshb
Copy link

ltshb commented Jun 8, 2023

Terraform Core Version

1.4.4

AWS Provider Version

5.1.0

Affected Resource(s)

aws_resourcegroups_resource
aws_ec2_capacity_reservation
aws_resourcegroups_group

Expected Behavior

Adding an EC2 Capacity reservation to a resource group

Actual Behavior

The creation of the aws_resourcegroups_resource to attach the aws_ec2_capacity_reservation to the aws_resourcegroups_group is failing with the error below.

Relevant Error/Panic Output Snippet

╷
│ Error: Plugin did not respond
│ 
│   with aws_resourcegroups_resource.eks["eu-central-1a"],
│   on resource-group.tf line 20, in resource "aws_resourcegroups_resource" "eks":
│   20: resource "aws_resourcegroups_resource" "eks" {
│ 
│ 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 aws_resourcegroups_resource.eks["eu-central-1c"],
│   on resource-group.tf line 20, in resource "aws_resourcegroups_resource" "eks":
│   20: resource "aws_resourcegroups_resource" "eks" {
│ 
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.
╵
╷
│ Error: Request cancelled
│ 
│   with aws_resourcegroups_resource.eks["eu-central-1b"],
│   on resource-group.tf line 20, in resource "aws_resourcegroups_resource" "eks":
│   20: resource "aws_resourcegroups_resource" "eks" {
│ 
│ The plugin.(*GRPCProvider).ApplyResourceChange request was cancelled.
╵
Releasing state lock. This may take a few moments...

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

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

goroutine 394 [running]:
github.com/hashicorp/terraform-provider-aws/internal/service/resourcegroups.resourceResourceCreate({0xf139e40, 0xc004d979e0}, 0x0?, {0xdc1b800?, 0xc00164a000?})
        github.com/hashicorp/terraform-provider-aws/internal/service/resourcegroups/resource.go:70 +0x4e5
github.com/hashicorp/terraform-provider-aws/internal/provider.interceptedHandler[...].func1(0x0?, {0xdc1b800?, 0xc00164a000?})
        github.com/hashicorp/terraform-provider-aws/internal/provider/intercept.go:108 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0xf139e40?, {0xf139e40?, 0xc004cf2c60?}, 0xd?, {0xdc1b800?, 0xc00164a000?})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/resource.go:702 +0x84
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0042ac2a0, {0xf139e40, 0xc004cf2c60}, 0xc008d72d00, 0xc00afd6780, {0xdc1b800, 0xc00164a000})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/resource.go:837 +0xa85
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0045cadf8, {0xf139e40?, 0xc004cf2300?}, 0xc003df30e0)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/grpc_provider.go:1021 +0xe8d
github.com/hashicorp/terraform-plugin-mux/tf5muxserver.muxServer.ApplyResourceChange({0xc0061672f0, 0xc006167350, {0xc0091208a0, 0x2, 0x2}, {0x0, 0x0, 0x0}, {0x0, 0x0, ...}, ...}, ...)
        github.com/hashicorp/terraform-plugin-mux@v0.10.0/tf5muxserver/mux_server_ApplyResourceChange.go:27 +0x102
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc002fea5a0, {0xf139e40?, 0xc006d919b0?}, 0xc00b4388c0)
        github.com/hashicorp/terraform-plugin-go@v0.15.0/tfprotov5/tf5server/server.go:818 +0x574
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xd9043a0?, 0xc002fea5a0}, {0xf139e40, 0xc006d919b0}, 0xc00b438850, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.15.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:419 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000bd7c20, {0xf14a620, 0xc00027c1a0}, 0xc008d40360, 0xc0091e1410, 0x15de8540, 0x0)
        google.golang.org/grpc@v1.54.0/server.go:1345 +0xdf0
google.golang.org/grpc.(*Server).handleStream(0xc000bd7c20, {0xf14a620, 0xc00027c1a0}, 0xc008d40360, 0x0)
        google.golang.org/grpc@v1.54.0/server.go:1722 +0xa2f
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        google.golang.org/grpc@v1.54.0/server.go:966 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.54.0/server.go:964 +0x28a

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

locals {
  aws_region         = "eu-central-1"
  env                = "development"
  cluster_name       = "dev"
  availability_zone = [
    "${local.aws_region}a",
    "${local.aws_region}b",
    "${local.aws_region}c"
  ]
}


resource "aws_resourcegroups_group" "eks" {
  name = "eks-${local.cluster_name}"

  resource_query {
    type  = "TAG_FILTERS_1_0"
    query = jsonencode({ ResourceTypeFilters = ["AWS::AllSupported"], TagFilters = [{ Key = "eks:cluster-name", Values = ["${local.cluster_name}"] }] })
  }
}

resource "aws_resourcegroups_resource" "eks" {
  for_each     = toset(local.availability_zone)
  group_arn    = aws_resourcegroups_group.eks.arn
  resource_arn = aws_ec2_capacity_reservation.k8s_upgrade[each.key].arn
}

resource "aws_ec2_capacity_reservation" "k8s_upgrade" {
  for_each          = toset(local.availability_zone)
  instance_type     = local.instance_type_b
  instance_platform = "Linux/UNIX"
  availability_zone = each.key
  instance_count    = local.desired_instances_b + 1

  tags = {
    Description = "Capacity reservation for cluster k8s ${local.env} upgrade"
  }
}

Steps to Reproduce

Apply the terraform configuration above

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

@ltshb ltshb added bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. labels Jun 8, 2023
@github-actions
Copy link

github-actions bot commented Jun 8, 2023

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • 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.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added crash Results from or addresses a Terraform crash or kernel panic. service/ec2 Issues and PRs that pertain to the ec2 service. service/resourcegroups Issues and PRs that pertain to the resourcegroups service. labels Jun 8, 2023
@justinretzolk
Copy link
Member

Hey @ltshb 👋 Thank you for taking the time to raise this! So that we have the information necessary to look into this, can you supply debug logs (redacted as needed) as well?

@justinretzolk justinretzolk removed service/ec2 Issues and PRs that pertain to the ec2 service. needs-triage Waiting for first response or review from a maintainer. labels Jun 8, 2023
@ewbankkit
Copy link
Contributor

_, err := conn.GroupResourcesWithContext(ctx, in)
if err != nil {
return create.DiagError(names.ResourceGroups, create.ErrActionCreating, ResNameResource, d.Get("name").(string), err)
}

This resource has no name attribute.

@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 Jul 30, 2023
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/resourcegroups Issues and PRs that pertain to the resourcegroups service.
Projects
None yet
3 participants