GoogleCloudPlatform / terraformer

CLI tool to generate terraform files from existing infrastructure (reverse Terraform). Infrastructure to Code
Apache License 2.0
12.47k stars 1.64k forks source link

Error when importing resource identitystore #1864

Closed jingjia-peng closed 2 months ago

jingjia-peng commented 5 months ago

I encounter this error when I'm calling terraformer import aws -c -r *, and when it comes to the check of identitystore this error occur:

2024/04/13 12:23:26 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(0xc0016750d0?)
        /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(0xc000da0af0?)
        /Users/sergey/temp/terraformer/providers/aws/aws_facade.go:61 +0x26
github.com/GoogleCloudPlatform/terraformer/cmd.initServiceResources({_, _}, {_, _}, {{0xc00156c800, 0x56, 0x80}, {0x12999268, 0x0, 0x0}, ...}, ...)
        /Users/sergey/temp/terraformer/cmd/import.go:209 +0x21e
github.com/GoogleCloudPlatform/terraformer/cmd.initAllServicesResources(_, {{0xc00156c800, 0x56, 0x80}, {0x12999268, 0x0, 0x0}, {0xb20575b, 0x1e}, {0xb15cdd8, ...}, ...}, ...)
        /Users/sergey/temp/terraformer/cmd/import.go:166 +0x1c5
github.com/GoogleCloudPlatform/terraformer/cmd.Import({_, _}, {{0xc00156c800, 0x56, 0x80}, {0x12999268, 0x0, 0x0}, {0xb20575b, 0x1e}, ...}, ...)
        /Users/sergey/temp/terraformer/cmd/import.go:98 +0x2a5
github.com/GoogleCloudPlatform/terraformer/cmd.importRegionResources({{0xc000baf830, 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(0xc001362580?, {0xb14e4f4?, 0x3?, 0x3?})
        /Users/sergey/temp/terraformer/cmd/provider_cmd_aws.go:66 +0x11e
github.com/spf13/cobra.(*Command).execute(0xc001362580, {0xc001550540, 0x3, 0x3})
        /Users/sergey/go/pkg/mod/github.com/spf13/cobra@v1.1.1/command.go:850 +0x67c
github.com/spf13/cobra.(*Command).ExecuteC(0xc000e51340)
        /Users/sergey/go/pkg/mod/github.com/spf13/cobra@v1.1.1/command.go:958 +0x39d
github.com/spf13/cobra.(*Command).Execute(...)
        /Users/sergey/go/pkg/mod/github.com/spf13/cobra@v1.1.1/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

Actually I don't have this resource on my aws, but it seems that terraformer fails on this case. BTW when I exclude identitystore the command goes well. Is this a bug or my fault?

nkoustov commented 5 months ago

I had the same issue with the officially released version (0.8.24). The version I built from the source code does not have this issue.

jeffrey-aguilera commented 5 months ago

Dup of #1832

github-actions[bot] commented 2 months ago

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] commented 2 months ago

This issue was closed because it has been stalled for 7 days with no activity.

samveen commented 1 month ago

Fixed in https://github.com/GoogleCloudPlatform/terraformer/issues/1808 . However, there's been no new release since the fix made it into the codebase. I did not hit this with self-built binary from HEAD (v0.8.24-35-gf3e9ae76)