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

Errors in multi region AWS resources import #1887

Closed
dkislov opened this issue Jun 20, 2024 · 3 comments
Closed

Errors in multi region AWS resources import #1887

dkislov opened this issue Jun 20, 2024 · 3 comments
Labels

Comments

@dkislov
Copy link

dkislov commented Jun 20, 2024

When running "terraformer import aws..." with multiple regions in the --regions option, errors are generated on the second region resources import:

ERROR: Read resource response is null for resource
ERROR: Unable to refresh resource

That is happening because of the caching of configuration in provider/aws/aws_service.go:

in
func (s *AWSService) generateConfig() (aws.Config, error) there is piece of code:

if configCache != nil {
return *configCache, nil
}

@dkislov dkislov changed the title Errors in multi region AWS resources Errors in multi region AWS resources import Jun 20, 2024
@amine-baaa
Copy link

A quick workaround that helped me was to clear the config cache explicitly before initiating the import for each region. You can achieve this by modifying the aws_service.go file to reset the configCache at the start of the generateConfig function.

Here's a brief patch that you might find useful:

func (s *AWSService) generateConfig() (aws.Config, error) {
    // Clear the cache to ensure a fresh config is generated for each region
    configCache = nil

    if configCache != nil {
        return *configCache, nil
    }
    ...
}

This change forces Terraformer to generate a new configuration for each region, which should prevent the errors you’re seeing.

If you're not comfortable modifying the source code directly, you might want to split your imports by region and run them sequentially in separate commands:

terraformer import aws --resources=identitystore --regions=us-east-1 --profile=terraform-imdiots
terraformer import aws --resources=identitystore --regions=us-west-1 --profile=terraform-imdiots

Copy link

github-actions bot commented Sep 3, 2024

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 github-actions bot added the Stale label Sep 3, 2024
Copy link

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

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants