【发布时间】:2021-06-21 16:21:00
【问题描述】:
我正在尝试将我的 Mac 上的 terraform 集成到 github。我已从 github 获取令牌并在以下代码中使用,但出现以下错误,可能是什么问题,
Error: GET https://api.github.com/user: 401 Bad credentials []
with provider["registry.terraform.io/integrations/github"],
on github.tf line 10, in provider "github":
10: provider "github" {
下面是代码供参考,
terraform {
required_providers {
github = {
source = "integrations/github"
version = "~> 4.0"
}
}
}
provider "github" {
token = "9f07bd456019eebe4b0341f52ad3f5ad434a8c58"
}
resource "github_repository" "terraform" {
name = "Terraform"
description = "Test for terraform intergration"
visibility = "private"
}
【问题讨论】:
-
您是否尝试通过 Github Actions 在您的 Github 存储库上使用 Terraform? (如果是,我建议看看市场,那里已经创建了许多使用 Terraform 的自动化工具,以便更轻松地管理该工具:github.com/marketplace?type=actions&query=terraform+)
-
不,我正在尝试通过在我的 PC 上运行代码,使用 terraform 在 github 中创建 repo。为此我需要将 terraform 与 github 集成,所以在这种情况下它失败了。