【问题标题】:Problem Initializing terraform with s3 backend - CredentialRequiresARNError使用 s3 后端初始化 terraform 时出现问题 - CredentialRequiresARNError
【发布时间】:2021-11-13 10:48:45
【问题描述】:

我在以下设置中初始化 terraform s3 后端时遇到问题。这适用于 terraform 版本 0.11.15,但适用于 0.15.5 和 1.0.7。

有2个文件:

terraform.tf

provider "aws" {
  region = "eu-west-1"
}

terraform {
  backend "s3" {
  }
}

resource "aws_s3_bucket" "this" {
  bucket = "test-bucket"
  acl    = "private"
}

test-env.tfvars

encrypt = true
dynamodb_table = "terraform-test-backend"
bucket = "terraform-test-backend"
key = "terraform/deployment/test-release.tfstate"
region = "eu-west-1"

当我使用 terraform 0.11.15 运行 terraform init -backend-config=test-env.tfvars 时,它可以工作并且我可以执行 terraform apply。这是输出:

Successfully configured the backend "s3"! Terraform will automatically                                                                                                                                                                        
use this backend unless the backend configuration changes.                                                                                                                                                                                    
                                                                                                                                                                                                                                              
Initializing provider plugins...                                                                                                                                                                                                              
- Checking for available provider plugins on https://releases.hashicorp.com...                                                                                                                                                                
- Downloading plugin for provider "aws" (2.70.0)...                                                                                                                                                                                           
* provider.aws: version = "~> 2.70"

但是当我尝试使用 0.15.5 和 1.0.7 版本时,我收到以下错误:

Error: error configuring S3 Backend: Error creating AWS session: CredentialRequiresARNError: credential type source_profile requires role_arn, profile default

任何想法如何解决它?

【问题讨论】:

    标签: amazon-web-services terraform terraform-provider-aws terraform0.12+ terraform0.15


    【解决方案1】:

    针对 s3 后端和 terraform 在 >0.13 版本中检查凭据的方式进行了一些更改。 看看following GitHub issue 或者更具体的 this one。此外,它在Changelog

    中列出

    我认为您面临的问题与您的 aws 配置文件的设置方式有关(请查看您的 ~/.aws/config)。

    【讨论】:

    • 谢谢 :-) 你说得对,配置文件配置错误。
    猜你喜欢
    • 2018-06-03
    • 1970-01-01
    • 1970-01-01
    • 2022-01-18
    • 1970-01-01
    • 2019-02-22
    • 2020-08-17
    • 1970-01-01
    • 2019-08-22
    相关资源
    最近更新 更多