aws-autoscaling-gitlab-runner icon indicating copy to clipboard operation
aws-autoscaling-gitlab-runner copied to clipboard

Missing Permission for Spot Instance Creation

Open MartinLoeper opened this issue 6 years ago • 5 comments

I use spot instances for runners. However, after setting GitLabRunnerSpotInstance to "Yes", the manager could not create the new machines and the logs stated that:

Error creating machine: Error in driver during machine creation: Error request spot instance: AuthFailure.ServiceLinkedRoleCreationNotPermitted: The provided credentials do not have permission to create the service-linked role for EC2 Spot Instances.

I had to add "iam:CreateServiceLinkedRole" for resource "*" to the manager's inline policy "Runners". I got the information from a related issue: https://github.com/AutoSpotting/AutoSpotting/issues/187

MartinLoeper avatar Nov 16 '18 17:11 MartinLoeper

Hi @MartinLoeper ! Thanks a lot for your interest in this project and your report.

I'm afraid I tested this on an account that already had a service linked role, so the iam:CreateServiceLinkedRole permission was not needed. 😱

I might try to force the creation of the service-linked role in the CloudFormation template to ensure it's present, but I wonder if that will work… 🤔

fquffio avatar Nov 18 '18 09:11 fquffio

Hi @fquffio, unfortunately I do not know which service linked role has to be created there. :laughing:

I just wanted to make it work as quickly as possible and adding the permission above works well. If you come up with a proper solution, I might test it on our infrastructure.

MartinLoeper avatar Nov 18 '18 21:11 MartinLoeper

I'll try to open a PR in the afternoon, but I'm afraid you'd have to delete all service-linked roles before testing… 😞

I might try to find an AWS account in which I have never used spot instances. 🤔

fquffio avatar Nov 19 '18 09:11 fquffio

I ran into the same issue. Here the PR #12

mpgo13 avatar Mar 22 '19 02:03 mpgo13

Looks like AWS creates the AWSServiceRoleForEC2Spot role automatically on the first ever spot instance request. So, if you make a spot request via aws (web), it will probably solve your problem

lamoglia avatar Nov 12 '19 22:11 lamoglia