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

Importing aws identitystore results in runtime error: index out of range #1891

Open
erados opened this issue Jun 28, 2024 · 3 comments
Open

Comments

@erados
Copy link

erados commented Jun 28, 2024

erados@songmyeong-uui-MacBookPro-2 tf % terraformer import aws --resources=identitystore  --path-pattern="{output}/" --connect=true --regions=us-east-1 --profile=terraform-imdiots
2024/06/28 18:50:31 aws importing region us-east-1
2024/06/28 18:50:32 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(0x14005944f78?)
        github.com/GoogleCloudPlatform/terraformer/providers/aws/identitystore.go:44 +0x180
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(0x140008f6aa0?)
        github.com/GoogleCloudPlatform/terraformer/providers/aws/aws_facade.go:61 +0x28
github.com/GoogleCloudPlatform/terraformer/cmd.initServiceResources({_, _}, {_, _}, {{0x140007eb330, 0x1, 0x1}, {0x1163b7300, 0x0, 0x0}, ...}, ...)
        github.com/GoogleCloudPlatform/terraformer/cmd/import.go:209 +0x214
github.com/GoogleCloudPlatform/terraformer/cmd.initAllServicesResources(_, {{0x140007eb330, 0x1, 0x1}, {0x1163b7300, 0x0, 0x0}, {0x16b1d7370, 0x9}, {0x10c8b56d0, ...}, ...}, ...)
        github.com/GoogleCloudPlatform/terraformer/cmd/import.go:166 +0x134
github.com/GoogleCloudPlatform/terraformer/cmd.Import({_, _}, {{0x140007eb330, 0x1, 0x1}, {0x1163b7300, 0x0, 0x0}, {0x16b1d7370, 0x9}, ...}, ...)
        github.com/GoogleCloudPlatform/terraformer/cmd/import.go:98 +0x1a0
github.com/GoogleCloudPlatform/terraformer/cmd.importRegionResources({{0x140007eae10, 0x1, 0x1}, {0x1163b7300, 0x0, 0x0}, {0x16b1d7370, 0x9}, {0x10c8b56d0, 0x9}, ...}, ...)
        github.com/GoogleCloudPlatform/terraformer/cmd/provider_cmd_aws.go:121 +0x260
github.com/GoogleCloudPlatform/terraformer/cmd.newCmdAwsImporter.func1(0x14001293b00?, {0x10c8a95ed?, 0x4?, 0x10c8a95c5?})
        github.com/GoogleCloudPlatform/terraformer/cmd/provider_cmd_aws.go:58 +0x778
github.com/spf13/cobra.(*Command).execute(0x14000e8f080, {0x14000851950, 0x5, 0x5})
        github.com/spf13/cobra@v1.1.1/command.go:850 +0x554
github.com/spf13/cobra.(*Command).ExecuteC(0x14000e8e000)
        github.com/spf13/cobra@v1.1.1/command.go:958 +0x310
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.1.1/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 +0x50
@amine-baaa
Copy link

It looks like you're running into a runtime error while importing AWS identity store resources with Terraformer. This error appears to stem from the GetIdentityStoreId function trying to access an index that doesn't exist.

  1. Validate Identity Store Configuration: Ensure that your AWS identity store is correctly set up and that the necessary permissions are in place. The error might be caused by an empty response from the AWS API.

  2. Debug Logging: Run Terraformer with increased logging verbosity to get more insights into what's causing the issue.

    TF_LOG=DEBUG terraformer import aws --resources=identitystore --path-pattern="{output}/" --connect=true --regions=us-east-1 --profile=terraform-imdiots
  3. Workaround: As a temporary measure, you might try manually specifying the identity store ID in your Terraformer command if that's an option. This can be done by setting the identity store ID directly in the resource configuration. For example:

    terraformer import aws --resources=identitystore --path-pattern="{output}/" --connect=true --regions=us-east-1 --profile=terraform-imdiots --identitystore-id=<your-identity-store-id>

    Replace <your-identity-store-id> with the actual identity store ID from your AWS account.

Also, it would be helpful if you could provide some additional details about your environment:

  • Terraformer version:
  • Go version:
  • OS and version:
  • Any specific configurations or custom setups:

@PabloPessolani
Copy link

I have the same error.
2024/08/12 11:23:51 aws done importing iam
2024/08/12 11:23:51 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(0xc00767d0d0?)
/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(0xc001ffe000?)
/Users/sergey/temp/terraformer/providers/aws/aws_facade.go:61 +0x26
github.com/GoogleCloudPlatform/terraformer/cmd.initServiceResources({, }, {, }, {{0xc000333800, 0x56, 0x80}, {0x12999268, 0x0, 0x0}, ...}, ...)
/Users/sergey/temp/terraformer/cmd/import.go:209 +0x21e
github.com/GoogleCloudPlatform/terraformer/cmd.initAllServicesResources(
, {{0xc000333800, 0x56, 0x80}, {0x12999268, 0x0, 0x0}, {0xb20575b, 0x1e}, {0xb15cdd8, ...}, ...}, ...)
/Users/sergey/temp/terraformer/cmd/import.go:166 +0x1c5
github.com/GoogleCloudPlatform/terraformer/cmd.Import({
, _}, {{0xc000333800, 0x56, 0x80}, {0x12999268, 0x0, 0x0}, {0xb20575b, 0x1e}, ...}, ...)
/Users/sergey/temp/terraformer/cmd/import.go:98 +0x2a5
github.com/GoogleCloudPlatform/terraformer/cmd.importRegionResources({{0xc0004a74a0, 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(0xc0004fd340?, {0xb14e4f4?, 0x4?, 0x4?})
/Users/sergey/temp/terraformer/cmd/provider_cmd_aws.go:58 +0xa0e
github.com/spf13/cobra.(*Command).execute(0xc0004fd340, {0xc0004bbac0, 0x4, 0x4})
/Users/sergey/go/pkg/mod/github.com/spf13/cobra@v1.1.1/command.go:850 +0x67c
github.com/spf13/cobra.(*Command).ExecuteC(0xc000b5bb80)
/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

@samveen
Copy link
Contributor

samveen commented Aug 24, 2024

Fixed in #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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants