GitLab: 4. Create the service

This documentation is part of the Automate with the CLI guide. View the full guide here: Start GitLab, retrieve its credentials, and change its configuration programmatically with the Stackhero CLI.

👋 Welcome to the Stackhero documentation!

Stackhero provides a ready-to-use GitLab cloud solution designed for teams that need a fast, secure, and scalable environment:

  • Unlimited users, repositories, data transfers, and CI/CD processing time for complete flexibility.
  • Effortless updates with a single click, so your environment stays current without downtime.
  • Custom domain name secured with HTTPS (for example, https://git.your-company.com) for professional branding and security.
  • Consistent performance and strong security on your own private, dedicated infrastructure. There are no noisy neighbors and you have full isolation.
  • Choice of hosting location: 🇪🇺 Europe or 🇺🇸 USA to suit your compliance or latency needs.

Get started fast and focus on your code. Stackhero's GitLab cloud hosting solution is ready to use in about 5 minutes.

Here is a sample script that creates a stack, adds your GitLab service to it, waits for it to start, retrieves its configuration (including generated credentials), and then applies a new configuration.

#!/bin/bash
set -e

export STACKHERO_TOKEN="usr-xxxxxx:your-token"

serviceStore="gitlab"   # The GitLab service store name (see step 2)
instance="..."                # An instance size from step 3
region="europe"               # A region name from step 3

# Create a stack for your service (uses your default organization; add --organization if needed)
stackId=$(stackhero --format=script stack-create \
  --name="My GitLab stack")
echo "Stack created: ${stackId}"

# Add GitLab to the stack (names are resolved automatically)
serviceId=$(stackhero --format=script service-add \
  --stack="My GitLab stack" \
  --service-store="${serviceStore}" \
  --instance="${instance}" \
  --region="${region}")
echo "Service added: gitlab"

# Wait for the service to be fully running (this may take a couple of minutes)
stackhero service-wait-for --service="gitlab"

# Retrieve the service configuration, including generated credentials
stackhero service-configuration-get --service="gitlab" --format=json