Hi all, this is my first post and appreciate your patience.
I am trying to setup a remote state for tfstate file and get an Error when running a ‘terraform init’. My examples are using an older versions, so I am adapting/RCA’ing/fixing as I go. I am currently picking up Terraform with limited time on AWS and all of its security mechanisms.
Here is the terraform block…
terraform {
required_providers {
aws = {
source = “hashicorp/aws”
version = “~> 5.75.0” }
}
required_version = “~> 1.9.8”
#Some creds issues.
backend "s3" {
bucket = "myUniqueBucketName"
key = "terraform.tfstate"
region = "us-east-1"
encrypt = true
}
… provider aws + aws_s3_bucket resource…
OUTPUT:
terraform init
Initializing the backend…
╷
│ Error: No valid credential sources found
│
│ Please see Backend Type: s3 | Terraform | HashiCorp Developer
│ for more information about providing credentials.
│
│ Error: 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: connectex: A socket operation was attempted to an unreachable network.
│
Your thoughts and help is appreciated!