英文:
why my basic terraform fails to run terraform plan?
问题
我有这个非常基本的Terraform文件:main.tf
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.16"
}
}
required_version = ">= 1.2.0"
}
provider "aws" {
profile = "default"
}
resource "aws_s3_bucket" "test-bucket-terraform-regergjegreg" {
bucket = "test-bucket-terraform-regergjegreg"
tags = {
Name = "My bucket"
Environment = "Dev"
}
}
在运行 terraform validate
时,我没有错误:
Success! The configuration is valid.
现在当我运行 terraform plan
时,我收到了这个错误:
Planning failed. Terraform encountered an error while generating this plan.
╷
│ Error: configuring Terraform AWS Provider: credential type source_profile requires role_arn, profile default
│
│ with provider["registry.terraform.io/hashicorp/aws"],
│ on main.tf line 12, in provider "aws":
│ 12: provider "aws" {
│
╵
这是我的Terraform版本:
Terraform v1.4.6
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v3.76.1
默认配置文件存在于我的 ~/.aws/credentials
和 ~/.aws/config
中。
不太确定问题出在哪里。感谢任何帮助。谢谢。
英文:
I have this very basic terraform file: main.tf
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.16"
}
}
required_version = ">= 1.2.0"
}
provider "aws" {
profile = "default"
}
resource "aws_s3_bucket" "test-bucket-terraform-regergjegreg" {
bucket = "test-bucket-terraform-regergjegreg"
tags = {
Name = "My bucket"
Environment = "Dev"
}
}
when doing terraform validate
, I have no error:
Success! The configuration is valid.
Now when I do terraform plan
, I got this error:
Planning failed. Terraform encountered an error while generating this plan.
╷
│ Error: configuring Terraform AWS Provider: credential type source_profile requires role_arn, profile default
│
│ with provider["registry.terraform.io/hashicorp/aws"],
│ on main.tf line 12, in provider "aws":
│ 12: provider "aws" {
│
╵
Here is my terraform version:
Terraform v1.4.6
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v3.76.1
the default profile exists in my /.aws/credentials and /.aws/config
Not sure what could be wrong really. Any help is appreciated. thanks
答案1
得分: 1
好的,我解决了这个问题。
我的问题不在凭证文件中,而在配置文件中。
出于某种原因,我有这个:
[default]
output = json
region = eu-west-1
source_profile = default
删除source_profile使其正常工作。
英文:
Ok, I resolved the issue.
My problem was not in credentials file but in config.
For some reason I had this:
[default]
output = json
region = eu-west-1
source_profile = default
removing source_profile makes it work.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论