clong / DetectionLab

Automate the creation of a lab environment complete with security tooling and logging best practices
MIT License
4.59k stars 979 forks source link

TF: Error: failed to refresh cached credentials, no EC2 IMDS role found, operation error ec2imds: Ge #818

Closed julianwieg closed 2 years ago

julianwieg commented 2 years ago

I am at a loss... any help appreciated

╷
│ Error: error configuring Terraform AWS Provider: no valid credential sources for Terraform AWS Provider found.
│ 
│ Please see https://registry.terraform.io/providers/hashicorp/aws
│ for more information about providing credentials.
│ 
│ Error: failed to refresh cached credentials, no EC2 IMDS role found, operation error ec2imds: GetMetadata, http response error StatusCode: 404, request to EC2 IMDS failed
│ 
│ 
│   with provider["registry.terraform.io/hashicorp/aws"],
│   on main.tf line 2, in provider "aws":
│    2: provider "aws" {
│ 
╵
julian@devbox:~/detectionlab/DetectionLab/AWS/Terraform$ aws ec2 describe-instances --profile terraform --region us-west-1
julian@devbox:~/detectionlab/DetectionLab/AWS/Terraform$ cat variables.tf | grep cred
variable "shared_credentials_file" {
  description = "Path to your AWS credentials file"
  default     = "~/.aws/credentials"
julian@devbox:~/detectionlab/DetectionLab/AWS/Terraform$ ls -lah ~/.aws/credentials
-rw------- 1 julian julian 234 May 27 12:54 /home/julian/.aws/credentials
julian@devbox:~/detectionlab/DetectionLab/AWS/Terraform$ ls -lah ~/.aws/config 
-rw------- 1 julian julian 102 May 27 14:51 /home/julian/.aws/config
julian@devbox:~/detectionlab/DetectionLab/AWS/Terraform$ terraform version
Terraform v1.2.1
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v4.15.1
julianwieg commented 2 years ago

fixed by putting path directly into main.tf not using variables.