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: runtime error: index out of range [0] with length 0 - terraform-provider-aws_v4.8.0_x5 #24031

Closed
asmi10 opened this issue Apr 5, 2022 · 4 comments · Fixed by #24298
Closed
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/efs Issues and PRs that pertain to the efs service.

Comments

@asmi10
Copy link

asmi10 commented Apr 5, 2022

Terraform CLI and Terraform AWS Provider Version

Affected Resource(s)

Terraform v1.1.7
on linux_amd64

  • provider registry.terraform.io/hashicorp/aws v4.8.0

Terraform Configuration Files

data "aws_efs_file_system" "efsfilesystem" {
  tags = {
     Name = "${var.pop_name}-honeycomb-efs"
  }
}

data "aws_ecr_repository" "honeycomb-gdb" {
     name = "honeycomb-mm-gdb"
}

data "aws_vpc" "vpc_info" {
  filter {
    name   = "tag:Name"
    values = ["${var.pop_name}_vpc"]
  }
}

data "aws_security_group" "efs_segrp" {
    name   = "${var.pop_name}-honeycomb-sg-efs"
}

resource "aws_subnet" "subnet1" {
  vpc_id = "${data.aws_vpc.vpc_info.id}"
  cidr_block = "172.32.50.0/24"

  tags = {
    Name = "${var.pop_name}-lambda-private-subnet-z1"
  }
}

resource "aws_subnet" "subnet2" {
  vpc_id = "${data.aws_vpc.vpc_info.id}"
  cidr_block = "172.32.51.0/24"

  tags = {
    Name = "${var.pop_name}-lambda-private-subnet-z2"
    Environment = "production"
}
}

Debug Output

Panic Output

Expected Behavior

Actual Behavior

Error: Plugin did not respond                                                                                                                                                                             
│                                                                                                                                                                                                           
│   with data.aws_efs_file_system.efsfilesystem,                                                                                                                                                            
│   on lambda.tf line 5, in data "aws_efs_file_system" "efsfilesystem":                                                                                                                                     
│    5: data "aws_efs_file_system" "efsfilesystem" {                                                                                                                                                        
│                                                                                                                                                                                                           
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ReadDataSource call. The plugin logs may contain more details.                                                       
╵                                                                                                                                                                                                           
╷                                                                                                                                                                                                           
│ Error: Plugin did not respond                                                                                                                                                                             
│                                                                                                                                                                                                           
│   with data.aws_ecr_repository.honeycomb-gdb,                                                                                                                                                             
│   on lambda.tf line 23, in data "aws_ecr_repository" "honeycomb-gdb":                                                                                                                                     
│   23: data "aws_ecr_repository" "honeycomb-gdb" {                                                                                                                                                         
│                                                                                                                                                                                                           
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ReadDataSource call. The plugin logs may contain more details.                                                       
╵                                                                                                                                                                                                           
╷                                                                                                                                                                                                           
│ Error: no matching EC2 VPC found                                                                                                                                                                          
│                                                                                                                                                                                                           
│   with data.aws_vpc.vpc_info,                                                                                                                                                                             
│   on lambda.tf line 31, in data "aws_vpc" "vpc_info":                                                                                                                                                     
│   31: data "aws_vpc" "vpc_info" {                                                                                                                                                                         
│                                                                                                                                                                                                           
╵                                                                                                                                                                                                           
╷                                                                                                                                                                                                           
│ Error: no matching SecurityGroup found                                                                                                                                                                    
│ 
│   with data.aws_security_group.efs_segrp,
│   on lambda.tf line 38, in data "aws_security_group" "efs_segrp":
│   38: data "aws_security_group" "efs_segrp" {
│ 
╵
╷
│ Error: Plugin did not respond
│ 
│   with data.aws_iam_policy.policy_two,
│   on lambda.tf line 121, in data "aws_iam_policy" "policy_two":
│  121: data "aws_iam_policy" "policy_two" {
│ 
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ReadDataSource call. The plugin logs may contain more details.
╵

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

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

goroutine 48 [running]:
github.com/hashicorp/terraform-provider-aws/internal/service/efs.dataSourceFileSystemRead(0x68, {0x78498c0, 0xc000207500})
        github.com/hashicorp/terraform-provider-aws/internal/service/efs/file_system_data_source.go:145 +0x997
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x9b48d80, {0x9b48d80, 0xc001988960}, 0xd, {0x78498c0, 0xc000207500})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.12.0/helper/schema/resource.go:347 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).ReadDataApply(0xc0003c2620, {0x9b48d80, 0xc001988960}, 0xc001b73e80, {0x78498c0, 0xc000207500})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.12.0/helper/schema/resource.go:578 +0x145
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadDataSource(0xc00000d038, {0x9b48cd8, 0xc0025ee6c0}, 0xc0019a0300)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.12.0/helper/schema/grpc_provider.go:1179 +0x3ba
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadDataSource(0xc0018a75e0, {0x9b48d80, 0xc0019880f0}, 0xc00198a0a0)
        github.com/hashicorp/terraform-plugin-go@v0.8.0/tfprotov5/tf5server/server.go:657 +0x45f
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadDataSource_Handler({0x8912520, 0xc0018a75e0}, {0x9b48d80, 0xc0019880f0}, 0xc0028c0120, 0x0)
 github.com/hashicorp/terraform-plugin-go@v0.8.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:421 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0001fec40, {0x9c43700, 0xc000f2e340}, 0xc001f846c0, 0xc0018d80f0, 0xf2a7270, 0x0)
        google.golang.org/grpc@v1.45.0/server.go:1282 +0xccf
google.golang.org/grpc.(*Server).handleStream(0xc0001fec40, {0x9c43700, 0xc000f2e340}, 0xc001f846c0, 0x0)
        google.golang.org/grpc@v1.45.0/server.go:1619 +0xa2a
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        google.golang.org/grpc@v1.45.0/server.go:921 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.45.0/server.go:919 +0x294

Error: The terraform-provider-aws_v4.8.0_x5 plugin crashed!
  1. terraform init
  2. terraform plan/apply

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. service/ecr Issues and PRs that pertain to the ecr service. service/efs Issues and PRs that pertain to the efs service. service/iam Issues and PRs that pertain to the iam service. labels Apr 5, 2022
@ewbankkit
Copy link
Contributor

if len(results) > 1 {
return fmt.Errorf("Search returned %d results, please revise so only one is returned", len(results))
}
fs := results[0]

@ewbankkit ewbankkit removed service/iam Issues and PRs that pertain to the iam service. service/ec2 Issues and PRs that pertain to the ec2 service. service/ecr Issues and PRs that pertain to the ecr service. needs-triage Waiting for first response or review from a maintainer. labels Apr 5, 2022
@sdlarsen
Copy link

sdlarsen commented Apr 8, 2022

Same with v4.9.0_x5


panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 148 [running]:
github.com/hashicorp/terraform-provider-aws/internal/service/ec2.expandLaunchTemplateInstanceMarketOptionsRequest(0xc000c239e0)
	github.com/hashicorp/terraform-provider-aws/internal/service/ec2/launch_template.go:1292 +0x18a
github.com/hashicorp/terraform-provider-aws/internal/service/ec2.expandRequestLaunchTemplateData(0x8c6f989)
	github.com/hashicorp/terraform-provider-aws/internal/service/ec2/launch_template.go:958 +0xfd7
github.com/hashicorp/terraform-provider-aws/internal/service/ec2.resourceLaunchTemplateUpdate(0xc00276ed00, {0x7921500, 0xc000744000})
	github.com/hashicorp/terraform-provider-aws/internal/service/ec2/launch_template.go:815 +0x145
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0x9c63900, {0x9c63900, 0xc002758ae0}, 0xd, {0x7921500, 0xc000744000})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.13.0/helper/schema/resource.go:730 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc001051880, {0x9c63900, 0xc002758ae0}, 0xc00277d860, 0xc00276eb80, {0x7921500, 0xc000744000})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.13.0/helper/schema/resource.go:848 +0x785
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0006a00f0, {0x9c63858, 0xc0024bd940}, 0xc002064dc0)
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.13.0/helper/schema/grpc_provider.go:1021 +0xe3c
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc000ed3360, {0x9c63900, 0xc002758420}, 0xc002485810)
	github.com/hashicorp/terraform-plugin-go@v0.8.0/tfprotov5/tf5server/server.go:812 +0x56b
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x8a08420, 0xc000ed3360}, {0x9c63900, 0xc002758420}, 0xc0018b01e0, 0x0)
	github.com/hashicorp/terraform-plugin-go@v0.8.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0001c2fc0, {0x9d60020, 0xc000751380}, 0xc0027547e0, 0xc0017a3f20, 0xf45b400, 0x0)
	google.golang.org/grpc@v1.45.0/server.go:1282 +0xccf
google.golang.org/grpc.(*Server).handleStream(0xc0001c2fc0, {0x9d60020, 0xc000751380}, 0xc0027547e0, 0x0)
	google.golang.org/grpc@v1.45.0/server.go:1619 +0xa2a
google.golang.org/grpc.(*Server).serveStreams.func1.2()
	google.golang.org/grpc@v1.45.0/server.go:921 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/grpc@v1.45.0/server.go:919 +0x294

Error: The terraform-provider-aws_v4.9.0_x5 plugin crashed!

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