terraformer icon indicating copy to clipboard operation
terraformer copied to clipboard

runtime error when importing `identitystore`

Open marafa-sugarcrm opened this issue 1 year ago • 6 comments

i keep getting this runtime error when importing identitystore. the command used was time terraformer import aws --profile=dev --regions=us-east-1 --resources="config"

2024/01/04 08:37:25 aws importing... identitystore
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/GoogleCloudPlatform/terraformer/providers/aws.(*IdentityStoreGenerator).GetIdentityStoreId(0x14001849098?)
	github.com/GoogleCloudPlatform/terraformer/providers/aws/identitystore.go:44 +0x198
github.com/GoogleCloudPlatform/terraformer/providers/aws.(*IdentityStoreGenerator).InitResources(0x0?)
	github.com/GoogleCloudPlatform/terraformer/providers/aws/identitystore.go:169 +0x20
github.com/GoogleCloudPlatform/terraformer/providers/aws.(*AwsFacade).InitResources(0x14003e17cc0?)
	github.com/GoogleCloudPlatform/terraformer/providers/aws/aws_facade.go:61 +0x28
github.com/GoogleCloudPlatform/terraformer/cmd.initServiceResources({_, _}, {_, _}, {{0x140007cd800, 0x56, 0x80}, {0x111d956f0, 0x0, 0x0}, ...}, ...)
	github.com/GoogleCloudPlatform/terraformer/cmd/import.go:209 +0x1a4
github.com/GoogleCloudPlatform/terraformer/cmd.initAllServicesResources(_, {{0x140007cd800, 0x56, 0x80}, {0x111d956f0, 0x0, 0x0}, {0x1084860ee, 0x1e}, {0x1083dd607, ...}, ...}, ...)
	github.com/GoogleCloudPlatform/terraformer/cmd/import.go:166 +0x134
github.com/GoogleCloudPlatform/terraformer/cmd.Import({_, _}, {{0x140007cd800, 0x56, 0x80}, {0x111d956f0, 0x0, 0x0}, {0x1084860ee, 0x1e}, ...}, ...)
	github.com/GoogleCloudPlatform/terraformer/cmd/import.go:98 +0x1a0
github.com/GoogleCloudPlatform/terraformer/cmd.importRegionResources({{0x140008d7740, 0x1, 0x1}, {0x111d956f0, 0x0, 0x0}, {0x1084860ee, 0x1e}, {0x1083dd607, 0x9}, ...}, ...)
	github.com/GoogleCloudPlatform/terraformer/cmd/provider_cmd_aws.go:121 +0x200
github.com/GoogleCloudPlatform/terraformer/cmd.newCmdAwsImporter.func1(0x14000cfe580?, {0x1083cebea?, 0x3?, 0x3?})
	github.com/GoogleCloudPlatform/terraformer/cmd/provider_cmd_aws.go:58 +0x804
github.com/spf13/cobra.(*Command).execute(0x14000cfe580, {0x14001682690, 0x3, 0x3})
	github.com/spf13/[email protected]/command.go:850 +0x4c4
github.com/spf13/cobra.(*Command).ExecuteC(0x14000ed0580)
	github.com/spf13/[email protected]/command.go:958 +0x34c
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/[email protected]/command.go:895
github.com/GoogleCloudPlatform/terraformer/cmd.Execute()
	github.com/GoogleCloudPlatform/terraformer/cmd/root.go:36 +0x20
main.main()
	github.com/GoogleCloudPlatform/terraformer/main.go:39 +0x54

marafa-sugarcrm avatar Jan 04 '24 15:01 marafa-sugarcrm

Same issue here. Not sure if it is relevant, but I am using version 5.33.0 of the AWS provider for Windows (AMD64).

Used command: terraformer plan aws --output hcl --resources="*" --verbose

Asgaros avatar Jan 19 '24 07:01 Asgaros

same issue here.

Informations

enviroment:

Pop!_OS 22.04 LTS x86_64 linux kernel v 6.6.6-76060606-generic

terraform:

$ terraform --version
Terraform v1.7.0
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v5.32.1

provider:

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.32.1"
    }
  }

command:

terraformer import aws --resources="*" --regions=eu-central-1

full output:

2024/01/24 13:08:31 aws importing region eu-central-1
2024/01/24 13:08:31 Attempting an import of ALL resources in aws
2024/01/24 13:08:32 aws importing... accessanalyzer
2024/01/24 13:08:32 aws error initializing resources in service accessanalyzer, err: operation error AccessAnalyzer: ListAnalyzers, failed to resolve service endpoint, an AWS region is required, but was not found
2024/01/24 13:08:32 aws importing... acm
2024/01/24 13:08:32 aws done importing acm
2024/01/24 13:08:32 aws importing... alb
2024/01/24 13:08:32 aws done importing alb
2024/01/24 13:08:32 aws importing... api_gateway
2024/01/24 13:08:33 aws done importing api_gateway
2024/01/24 13:08:33 aws importing... appsync
2024/01/24 13:08:33 aws done importing appsync
2024/01/24 13:08:33 aws importing... auto_scaling
2024/01/24 13:08:34 aws done importing auto_scaling
2024/01/24 13:08:34 aws importing... batch
2024/01/24 13:08:34 aws done importing batch
2024/01/24 13:08:34 aws importing... budgets
2024/01/24 13:08:35 aws done importing budgets
2024/01/24 13:08:35 aws importing... cloud9
2024/01/24 13:08:35 aws done importing cloud9
2024/01/24 13:08:35 aws importing... cloudformation
2024/01/24 13:08:35 aws done importing cloudformation
2024/01/24 13:08:35 aws importing... cloudfront
2024/01/24 13:08:36 aws done importing cloudfront
2024/01/24 13:08:36 aws importing... cloudhsm
2024/01/24 13:08:36 aws done importing cloudhsm
2024/01/24 13:08:36 aws importing... cloudtrail
2024/01/24 13:08:37 aws done importing cloudtrail
2024/01/24 13:08:37 aws importing... cloudwatch
2024/01/24 13:08:38 aws done importing cloudwatch
2024/01/24 13:08:38 aws importing... codebuild
2024/01/24 13:08:38 aws done importing codebuild
2024/01/24 13:08:38 aws importing... codecommit
2024/01/24 13:08:38 aws done importing codecommit
2024/01/24 13:08:38 aws importing... codedeploy
2024/01/24 13:08:38 aws done importing codedeploy
2024/01/24 13:08:38 aws importing... codepipeline
2024/01/24 13:08:39 aws done importing codepipeline
2024/01/24 13:08:39 aws importing... cognito
2024/01/24 13:08:39 aws done importing cognito
2024/01/24 13:08:39 aws importing... config
2024/01/24 13:08:39 aws done importing config
2024/01/24 13:08:39 aws importing... customer_gateway
2024/01/24 13:08:40 aws done importing customer_gateway
2024/01/24 13:08:40 aws importing... datapipeline
2024/01/24 13:08:41 aws done importing datapipeline
2024/01/24 13:08:41 aws importing... devicefarm
2024/01/24 13:08:46 aws done importing devicefarm
2024/01/24 13:08:46 aws importing... docdb
2024/01/24 13:08:46 aws done importing docdb
2024/01/24 13:08:46 aws importing... dynamodb
2024/01/24 13:08:46 aws done importing dynamodb
2024/01/24 13:08:46 aws importing... ebs
2024/01/24 13:08:46 aws done importing ebs
2024/01/24 13:08:46 aws importing... ec2_instance
2024/01/24 13:08:47 aws done importing ec2_instance
2024/01/24 13:08:47 aws importing... ecr
2024/01/24 13:08:47 aws done importing ecr
2024/01/24 13:08:47 aws importing... ecrpublic
2024/01/24 13:08:48 aws done importing ecrpublic
2024/01/24 13:08:48 aws importing... ecs
2024/01/24 13:08:48 aws done importing ecs
2024/01/24 13:08:48 aws importing... efs
2024/01/24 13:08:48 aws done importing efs
2024/01/24 13:08:48 aws importing... eip
2024/01/24 13:08:49 aws done importing eip
2024/01/24 13:08:49 aws importing... eks
2024/01/24 13:08:49 aws done importing eks
2024/01/24 13:08:49 aws importing... elastic_beanstalk
2024/01/24 13:08:49 aws done importing elastic_beanstalk
2024/01/24 13:08:49 aws importing... elasticache
2024/01/24 13:08:50 aws done importing elasticache
2024/01/24 13:08:50 aws importing... elb
2024/01/24 13:08:50 aws done importing elb
2024/01/24 13:08:50 aws importing... emr
2024/01/24 13:08:50 aws done importing emr
2024/01/24 13:08:50 aws importing... eni
2024/01/24 13:08:50 aws done importing eni
2024/01/24 13:08:50 aws importing... es
2024/01/24 13:08:51 aws done importing es
2024/01/24 13:08:51 aws importing... firehose
2024/01/24 13:08:51 aws done importing firehose
2024/01/24 13:08:51 aws importing... glue
2024/01/24 13:08:51 aws done importing glue
2024/01/24 13:08:51 aws importing... iam
2024/01/24 13:08:58 aws done importing iam
2024/01/24 13:08:58 aws importing... identitystore
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/GoogleCloudPlatform/terraformer/providers/aws.(*IdentityStoreGenerator).GetIdentityStoreId(0xc00619b0d0?)
        /Users/sergey/temp/terraformer/providers/aws/identitystore.go:44 +0x1ce
github.com/GoogleCloudPlatform/terraformer/providers/aws.(*IdentityStoreGenerator).InitResources(0x0?)
        /Users/sergey/temp/terraformer/providers/aws/identitystore.go:169 +0x25
github.com/GoogleCloudPlatform/terraformer/providers/aws.(*AwsFacade).InitResources(0xc00230f720?)
        /Users/sergey/temp/terraformer/providers/aws/aws_facade.go:61 +0x26
github.com/GoogleCloudPlatform/terraformer/cmd.initServiceResources({_, _}, {_, _}, {{0xc000d8b800, 0x56, 0x80}, {0x12999268, 0x0, 0x0}, ...}, ...)
        /Users/sergey/temp/terraformer/cmd/import.go:209 +0x21e
github.com/GoogleCloudPlatform/terraformer/cmd.initAllServicesResources(_, {{0xc000d8b800, 0x56, 0x80}, {0x12999268, 0x0, 0x0}, {0xb20575b, 0x1e}, {0xb15cdd8, ...}, ...}, ...)
        /Users/sergey/temp/terraformer/cmd/import.go:166 +0x1c5
github.com/GoogleCloudPlatform/terraformer/cmd.Import({_, _}, {{0xc000d8b800, 0x56, 0x80}, {0x12999268, 0x0, 0x0}, {0xb20575b, 0x1e}, ...}, ...)
        /Users/sergey/temp/terraformer/cmd/import.go:98 +0x2a5
github.com/GoogleCloudPlatform/terraformer/cmd.importRegionResources({{0xc000598e60, 0x1, 0x1}, {0x12999268, 0x0, 0x0}, {0xb20575b, 0x1e}, {0xb15cdd8, 0x9}, ...}, ...)
        /Users/sergey/temp/terraformer/cmd/provider_cmd_aws.go:121 +0x292
github.com/GoogleCloudPlatform/terraformer/cmd.newCmdAwsImporter.func1(0xc000dcc580?, {0xb14e4f4?, 0x2?, 0x2?})
        /Users/sergey/temp/terraformer/cmd/provider_cmd_aws.go:58 +0xa0e
github.com/spf13/cobra.(*Command).execute(0xc000dcc580, {0xc000aae9a0, 0x2, 0x2})
        /Users/sergey/go/pkg/mod/github.com/spf13/[email protected]/command.go:850 +0x67c
github.com/spf13/cobra.(*Command).ExecuteC(0xc000cff340)
        /Users/sergey/go/pkg/mod/github.com/spf13/[email protected]/command.go:958 +0x39d
github.com/spf13/cobra.(*Command).Execute(...)
        /Users/sergey/go/pkg/mod/github.com/spf13/[email protected]/command.go:895
github.com/GoogleCloudPlatform/terraformer/cmd.Execute()
        /Users/sergey/temp/terraformer/cmd/root.go:36 +0x1e
main.main()
        /Users/sergey/temp/terraformer/main.go:39 +0x50

Temporary workaround

Since the problem seams to only affect identitystore the problem can be avoided adding --excludes="identitystore" like below. (of course "identitystore" resources will not be considered)

terraformer [command] [provider] [flags] --excludes="identitystore"

emanuele-scarsella avatar Jan 24 '24 12:01 emanuele-scarsella

getting the same error with the following combination under linux

# terraform --version
Terraform v1.7.4
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v5.38.0
# terraformer --version
version v0.8.24

matsui-p avatar Feb 29 '24 13:02 matsui-p

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar May 01 '24 01:05 github-actions[bot]

Same issue with version = "~> 5.47"

jeffrey-aguilera avatar May 02 '24 22:05 jeffrey-aguilera

Probably introduced in #1685 ?

It's an issue with the latest release i.e. v0.8.24. My environment:

samveen@zero2w:~$ aws --version
aws-cli/2.16.4 Python/3.11.8 Linux/6.6.28+rpt-rpi-v8 exe/aarch64.debian.12
samveen@zero2w:~$ tf --version
Terraform v1.8.5
on linux_arm64
samveen@zero2w:~$ terraformer --version
version v0.8.24
samveen@zero2w:~$ grep -Ev '^\s*$|^s\*#'  ~/workspace/infrastructure-repository/provider.tf 
terraform {
  required_providers {
    aws = {
      source = "hashicorp/aws"
      version = "5.53.0"
    }
  }
}
provider "aws" {
  # Configuration options
  region  = var.region
}

samveen avatar Jun 11 '24 15:06 samveen

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Aug 14 '24 01:08 github-actions[bot]