Skip to content


Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Autoscaling EC2 GitLab Runners Spawned by Fargate

The purpose of the CloudFormation template is to create a Fargate Service that manages and autoscales EC2 instances to serve as a Gitlab CI executors. This allows for private GitLab Runners without managing, patching or maintaining servers.

Why Use EC2 executors?

At the time of writing, Fargate doesn't support the privileged task definition parameter for executors which ultimately means you can't use Docker-in-Docker to build/pull/push docker images in a Fargate executor. Anyone who is looking for a pure Fargate implementation should read this.

Launch CloudFormation



  • VpcId - Select a VPC that allows instances access to the Internet
  • SubnetID - Select subnets - Must be in the selected VPC!
  • GitLabURL - The Gitlab URL, change if self-hosted
  • GitLabRegistrationToken - The Gitlab runer registration token
  • RunnerRequestConcurrency - Specify the number of concurrent EC2 virtual machines to spawn (defaults to 12)
  • RunnerTagList - Optional parameter to specify the gitlab-runner tags (Example "docker,aws")
  • AdditionalRegisterParams - Any additional parameters you want to pass to gitlab-runner register
  • RunnerVersion The GitLab runner version
  • InstanceType - The instance type of the runners
  • RootVolumeSize -The size of the root volume on the runners
  • CacheExpirationInDays - Select how long to store a jobs cache output in S3
  • CPU - Set the number of CPUs for the spawner (1 CPU = 1024)
  • Memory - Set the amount of RAM in KB for the spawner
  • DockerImage - The default docker image if not provided in a gitlab-ci.yml file

Resource Created

  • IAM User - Used to connect to S3
  • IAM Roles for ECS
  • S3 Bucket for runner cache
  • ECS Cluster, Service & Task Definition
  • CloudWatch Logs Groups that streams to logs for the spawner