Terraform Cloud - Unable to discover GitLab VCS Repos/Branches

Kasanne Smith
Giga Contributor

Hi all,

I've spun up a dev instance to test CPG and Terraform Cloud and I'm quite new to SNow, so far I've successfully discovered the Terraform Cloud provider and can view my Workspaces and connected VCS. The issue I'm having is when I go into the GitLab VCS and attempt to "Find Branches and Repositories" using the related link, it loads, says it's successful, but nothing appears.

The GitLab token I'm using was created in this page - https://gitlab.com/-/profile/personal_access_tokens - I've selected the "api, read_api, read_user, read_repository" scopes and created a credential in SNow like "Token glpat-xxxxxxxxxxxxxxxxxxxx" as stated in the documentation. Doco states only to create a Credential Alias for the Config Provider cred so there's no alias for this one.

 

After discovery, the newest log says it's successful

But before that there's a few warnings which I'm not sure are related or not

 

And this error

 

My GitLab repos are private as they are meant to be according to the doco as well. Also, on this page it says "Locate and save the "OAuth Token ID" for the VCS provider or providers you will be using with Cloud Provisioning and Governance. Terraform uses the OAuth token ID to identify and authorize the VCS provider." but I have no idea where to put this token and was thinking that might be the issue too.

Any help would be appreciated!

1 ACCEPTED SOLUTION

Well it appears that the documentation is not correct; maybe.

From San Diego document portal

Click the required record from the Terraform Enterprise VCS list and select or create an API key credential for the VCS (GitHub) repository.

Note: Use this format for the VCS system's API key credential: Token<SPACE>< GENERATED-KEY>. For example,Token fabcdefgh123.

After reading some API specification on GitLab it appears that personal tokens should use

Bearer<SPACE>< GENERATED-KEY>

 

Once I changed the credential, I was able to get the repositories and branches.

 

Hope this helps someone

View solution in original post

8 REPLIES 8

Yep, that's the issue. The doco as-is only works for GitHub.

 

Cheers!

jitesh123
Tera Contributor

I am also facing same issue. I have generated organization token ID, however in API credential which API key to use?

question is not clear - please start a new thread with full details.

jitesh123
Tera Contributor

jitesh123_0-1688819205088.png

This is Terraform cloud API key at organization level and syntax given is Bearer <API KEY>