This does not work:
create.tf
terraform {
required_providers {
gitlab = {
source = "gitlabhq/gitlab"
}
}
}
variable "gitlab_token" {
type = string
default = "SECRET"
}
variable "base_url" {
type = string
default = "https://gitlab.com/errooorr/api/v4/"
}
provider "gitlab" {
token = var.gitlab_token
base_url = var.base_url
terraform.tfvars:gitlab_token = blablabla
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
It looks like you haven’t closed your provider block. Your create.tf file should be like the following:
terraform {
required_providers {
gitlab = {
source = "gitlabhq/gitlab"
}
}
}
variable "gitlab_token" {
type = string
default = "SECRET"
}
variable "base_url" {
type = string
default = "https://gitlab.com/errooorr/api/v4/"
}
provider "gitlab" {
token = var.gitlab_token
base_url = var.base_url
}
Your terraform.tfvars file is correctly set up. The terraform variables file should be like this:
gitlab_token = "blablabla"
Ensure you replace "blablabla" with your actual GitLab token.
A couple of other points to consider:
Check that your base_url is correct. The base url should be the GitLab API endpoint. The usual endpoint for GitLab’s API is https://gitlab.com/api/v4/.
Ensure you have installed the correct GitLab provider. You can do this by running the following command in the directory where your .tf files are located:
terraform init
After setting the correct values and making sure everything is correctly set up, apply your configuration by running:
terraform apply
If you have sensitive data like tokens, it’s not recommended to put the real values directly in the scripts or code. Use secrets management tools to handle such information.
Check your GitLab token permissions. It should have the necessary permissions for the operations you are trying to perform.
I could also suggest going over the official documentation here:
https://registry.terraform.io/providers/gitlabhq/gitlab/latest/docs
Best,
Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.