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

Ram Devanathan1
ServiceNow Employee
ServiceNow Employee

Please work with support, log a case and share the id.

Ram

Mike Vukicevich
Tera Expert

I am having the same issue. Was there a resolution identified?

Using Gitlab private repository with user access token. Same behavior and error.

 

Would love to get a reply from someone from ServiceNow or someone that has had this issue and fixed it.

 

Thanks

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

Hi Mike, good find - it is confusing I agree.

there's point 4 in the doc page here that does indicate using bearer for access key with GitHub but it is lost and out of place.

we will raise a doc task and get this fixed.

regards,

Ram

Sr. Principal Product Manager

Cloud Mgmt Products, ITOM