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

Open
dkislov opened this issue Jun 20, 2024 · 1 comment
Open

Errors in multi region AWS resources import #1887

dkislov opened this issue Jun 20, 2024 · 1 comment

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

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

2 participants