Built in variable for VCS project ID/Path
We are currently using GitLab as our VCS. Each project that is linked to spacelift has a project path and ID. We use this information in our terraform for the secrets integration. It would be nice to have a variable auto populated in spacelift for these two pieces of information, so that a user doesn’t need to hard code the project path into the terraform.
- Workaround
Log in to comment and vote
Comments1
Aleksandra Cieslak
Jul 16
Hi, thanks for the detailed request and sorry for the long silence here.
Good news: part of what you're asking for already exists. Every run has access to
TF_VAR_spacelift_repository, a built-in environment variable that exposes the repository inowner/repoformat, which for GitLab is your project path. You can find it (and other built-in metadata) in the Environment section of your stack, or in our docs: https://docs.spacelift.io/concepts/configuration/environment#spacelift-environmentFor the numeric project ID specifically we don't expose that as a built-in variable today. However, GitLab's REST API accepts a URL-encoded project path as a substitute for the numeric ID in the
:idpath parameter on most endpoints.Let me know if this was helpful!