使用Terraform构建GitLab项目
我正在尝试使用内置的Terraform提供程序“”在Terraform中构建GitLab项目/回购。这看起来很简单,但是当我使用Terraform构建GitLab项目,gitlab,terraform,Gitlab,Terraform,我正在尝试使用内置的Terraform提供程序“”在Terraform中构建GitLab项目/回购。这看起来很简单,但是当我$terraformplan我下面的文件时,我意外地得到了以下错误 terraform { required_version = ">= 0.11.0" } provider "gitlab" { token = "<valid-token-id>" } resource "gitlab_project" "my_repo" { name
$terraformplan
我下面的文件时,我意外地得到了以下错误
terraform {
required_version = ">= 0.11.0"
}
provider "gitlab" {
token = "<valid-token-id>"
}
resource "gitlab_project" "my_repo" {
name = "My Repo"
namespace_id = 85
}
// ERROR RETURNED BELOW
Error: Error running plan: 1 error(s) occurred:
* provider.gitlab: GET https://gitlab.com/api/v4/user: 401 {message:
401 Unauthorized}
此外,该令牌来自具有完全GitLab访问权限的超级用户
我确实意识到这是成功的curl
调用和terraform plan
调用的两个独立端点。我有没有办法配置Terraform在规划/应用时会遇到什么端点?有人有过这样的经历吗?谢谢
我是个大傻瓜。我只需要指定base\u url
(包括/api/v4/
)
提供程序“gitlab”{
token=“”
基本url=”https://.githost.io/api/v4/"
}
Epic high five向您致意。可以肯定,默认情况下使用的是gitlab.com,而不是旧式的githost.io(我认为不再提供此功能,但这里可能有误)。您还应该在提供者定义中设置
base\u url
,除非您是通过环境变量设置的?
$ curl https://<mycompany>.githost.io/api/v4/projects?private_token=$GITLAB_TOKEN
provider "gitlab" {
token = "<valid-token>"
base_url = "https://<mycompany>.githost.io/api/v4/"
}