- the Registration Token for Specific project, or Group project (Recommend).
- AWS account with Policies (or permissions) to use cloudformation.
- EC2 key pair. Tutorial [here][https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html]
- With the registration token, we are going to register a new Runner and generate an <AUTHENTICATION_TOKEN>
-
Run the next command in a terminal:
curl --header "PRIVATE-TOKEN: <REGISTER_TOKEN>" "https://gitlab.com/api/v4/runners"
-
The response looks like this:
{"id":<NUMBER_ID>,"token":<AUTHENTICATION_TOKEN>}
Note: Don't forget save the <AUTHENTICATION_TOKEN>
-
Now, we are going to use a template to create an stack in cloudformation. Just open the repository[1] and click in Launch Stack button
-
In template, Just fill information:
- Use the <AUTHENTICATION_TOKEN> in "GitlabToken" Input
- Use the KeyPair you already created
- Select in "use spot instance" yes
- Select in spot instance, the value you want to pay (recommend 0.03)
Note:
- Some Avaiability zones does not support nano and micro instances
- The ec2 and s3 shouldn't exist. the template creates all resources
- You should give IAM ROLE CAPABILITY to cloudformation template, just select in last step the checkbox "I acknowledge that AWS CloudFormation might create IAM resources"
-
Check the progress in cloudformation, it takes around 5-10 minutes. If something is wrong, check the AWS cloudformation event tab
-
If everything is ok, the new Runner should appear in Runner section in your project or group
[1] https://github.com/chialab/aws-autoscaling-gitlab-runner