Answer a question

[----------------------- UPDATE --------------------------]

I have tried a tutorial to integrate terraform with s3 now. The S3 bucket is created and I have created an IAM user, and I am using its Access key and secret key. Nonetheless I keep getting errors regarding the providers after terraform init:

backend.tf

terraform {
  required_version = ">=0.12.0"
  backend "s3" {
    region  = "us-east-1"
    key     = "terraform.tfstate"
    profile = "tu"
    bucket  = "terraformstatebucket3107"
  }
}

config file in .aws folder

[tu]
region = us-east-1
output = json

credentials file in .aws folder

[tu]
aws_access_key_id = AKIA*****************
aws_secret_access_key = nn3M1*****************

Error:

Initializing the backend...

Error: error configuring S3 Backend: no valid credential sources for S3 Backend found.

Please see https://www.terraform.io/docs/backends/types/s3.html
for more information about providing credentials.

Error: NoCredentialProviders: no valid providers in chain. Deprecated.
    For verbose messaging see aws.Config.CredentialsChainVerboseErrors

Answers

So, I have tried every solution that was suggested here, but unfortunately none of them solved my issue. After some digging, I found a solution that worked for me. That was executing the terraform init command with the -backend-config option like this:

terraform init -backend-config="access_key=<your access key>" -backend-config="secret_key=<your secret key>"

This is the question where I found this solution: Error while configuring Terraform S3 Backend

Logo

云原生社区为您提供最前沿的新闻资讯和知识内容

更多推荐