GoogleCloudPlatform / terraformer

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

Issue if not supplying profile, and attempting to use env vars for aws access key and secret key #1898

Open Lewiscowles1986 opened 1 month ago

Lewiscowles1986 commented 1 month ago

Hey, thanks for the cool software.

Something strange (to me); is that this seems to require me to setup AWS in a specific way (using profiles).

I set this up on a vanilla machine and attempted to use the following env variables:

My provider.tf

provider "aws" {
  region = "eu-west-1"  # Change to your desired region
}

Finally, I ran with the command terraformer import aws --resources=cognito --regions=eu-west-1

This did not work, and raised this error:

lewiscowles@Lewiss-MacBook-Air cognito-okta % terraformer import aws --resources=cognito --regions=eu-west-1 2024/07/11 05:48:19 aws importing region eu-west-1 2024/07/11 05:48:21 aws importing... cognito 2024/07/11 05:48:25 aws error initializing resources in service cognito, err: failed to refresh cached credentials, no EC2 IMDS role found, operation error ec2imds: GetMetadata, exceeded maximum number of attempts, 3, request send failed, Get "http://169.254.169.254/latest/meta-data/iam/security-credentials/": dial tcp 169.254.169.254:80: connect: host is down 2024/07/11 05:48:25 aws Connecting....

Lewiscowles1986 commented 1 month ago

For-now fix is to run aws configure, and fill in the details so a default profile is present. Meh, I guess it works.