使用 s3 后端初始化 terraform 时出现问题 - CredentialRequiresARNError
Problem Initializing terraform with s3 backend - CredentialRequiresARNError
我在以下设置中初始化 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"
}
测试-env.tfvars
encrypt = true
dynamodb_table = "terraform-test-backend"
bucket = "terraform-test-backend"
key = "terraform/deployment/test-release.tfstate"
region = "eu-west-1"
当我 运行 terraform init -backend-config=test-env.tfvars
使用 terraform 0.11.15 时,它起作用了,我可以执行 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
有什么解决办法吗?
在版本 >0.13 中引入了一些关于 s3 后端和 Terraform 检查凭据的方式的变化。
看看 following GitHub issue or even more specifically this one. In addition its outlined in the Changelog
我认为您面临的问题与您的 aws 配置文件设置方式有关(检查您的 ~/.aws/config
)。
我在以下设置中初始化 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"
}
测试-env.tfvars
encrypt = true
dynamodb_table = "terraform-test-backend"
bucket = "terraform-test-backend"
key = "terraform/deployment/test-release.tfstate"
region = "eu-west-1"
当我 运行 terraform init -backend-config=test-env.tfvars
使用 terraform 0.11.15 时,它起作用了,我可以执行 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
有什么解决办法吗?
在版本 >0.13 中引入了一些关于 s3 后端和 Terraform 检查凭据的方式的变化。 看看 following GitHub issue or even more specifically this one. In addition its outlined in the Changelog
我认为您面临的问题与您的 aws 配置文件设置方式有关(检查您的 ~/.aws/config
)。