【问题标题】:Terraform plan using terraform cloud back end AWS credential error使用 terraform 云后端 AWS 凭证错误的 Terraform 计划
【发布时间】:2021-09-03 23:49:01
【问题描述】:

上下文:

  • 我已使用 aws configure 设置了我的 aws 凭据。
  • 我使用 terraform 远程后端来存储 terraform 状态

使用以下 terraform 配置。

terraform {
 backend "remote" {
   hostname     = "app.terraform.io"
   organization = "test"

   workspaces {
     prefix = "networking-"
   }
 }
}

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

问题: 当我运行 terraform apply 时出现此错误。

    ╷
    │ Error: No valid credential sources found for AWS Provider.
    │       Please see https://terraform.io/docs/providers/aws/index.html for more information on
    │       providing credentials for the AWS Provider
    │ 
    │   with provider["registry.terraform.io/hashicorp/aws"],
    │   on main.tf line 13, in provider "aws":
    │   13: provider "aws" {
    │ 
    ╵

【问题讨论】:

标签: amazon-web-services terraform terraform-provider-aws


【解决方案1】:

如果您在创建工作空间时默认使用 terraform cloud 远程后端,则 terraform plan 命令在远程后端而不是本地计算机上执行。这就是为什么 terraform 找不到您的凭据的原因,因为它们没有在远程机器中设置。要解决此问题,您需要订购 terraform 以在您的机器上运行该计划。这样做 进入你的工作区 然后进入常规设置 然后从远程执行模式切换到本地

然后尝试在您的机器上再次运行您的计划

【讨论】:

  • 因此您无需将 AWS 密钥作为环境变量移植到 terraform 云,只需将状态管理移植到 Terraform 云即可继续在本地(计划、应用)使用 terraform
猜你喜欢
  • 2019-06-13
  • 2021-05-07
  • 1970-01-01
  • 1970-01-01
  • 2018-05-12
  • 2020-09-03
  • 1970-01-01
  • 2020-09-18
  • 2020-10-15
相关资源
最近更新 更多