Terraforming my gitlab projects, on gitlab

Share on:

alt text

I guess it is one of these moments that you need to clean up your room (or maybe the whole house), it's not super messy, but it is messy enough to make you keep thinking about it. So one day (or night) you make the call, that's it, I need to clean up. This is how I felt about my personal gitlab account. I won't deny it, I love Gitlab and in the past 2 years I have moved most of my non work_ coding activities there (making my Github account look - inactive, oh well). I truly enjoy working with their CI and the fact that they give you _free CI minutes is super helpful. Lately I have been coding a lot during late night sessions, trying things here and there, which resulted to a lot of different repos on my list. I found my self loosing time trying to find what is what, plus I had to do repetitive point and click work. Maybe add a variable here and there, add a friend as a collaborator etc.

If you want to jump directly to the repo (and clone it) you can find it in the link below:


Some notes on the example:

  • This is just a skeleton to get you started it features the following:

  • Define 2 project groups (public and private)

  • Create 2 repos (public and private) and link them to the above groups

  • Add a couple of users as collaborators to the projects (for example a friend? or a bot?)

  • Define a group variable/ project variable.

  • I am making use of the Terraform AWS S3 backend to store my stack's state. I have a dedicated S3 bucket for most of my terraform experiments, so I am used of it. This does not mean that you have to store your state to an S3 bucket. For example, you can even use Gitlab as your _remote state backend .

  • I am using a Gitlab-CI pipeline to run my terraform (see .gitlab-ci.yml_) - it's mostly a copy and paste of the _gitlab template, see References below.

  • In order for the pipeline to run I need to inject the following variables (I added them on the Variables section of the gitlab project, and are injected on the pipelines' environment):

  • $GITLAB_ACCESS_TOKEN : (You need to create one from your User Settings on Gitlab, it is required so that the Gitlab Terraform provider can issue API calls to Gitlab)




  • The AWS keys are needed so that I can _save my state to the S3 bucket. If you don't use S3 as your state store, then you don't need them.