AWS EC2实例无法注册为GitHub自托管运行器问题排查
问题:EC2实例无法注册为GitHub自托管运行器超时错误
运行注册流程时出现以下超时错误:
GitHub Registration Token is received AWS EC2 instance i-abcd is started AWS EC2 instance i-abcd is up and running Waiting 30s for the AWS EC2 instance to be registered in GitHub as a new self-hosted runner Checking every 10s if the GitHub self-hosted runner is registered Checking... Checking... Error: GitHub self-hosted runner registration error Checking... Error: A timeout of 5 minutes is exceeded. Your AWS EC2 instance was not able to register itself in GitHub as a new self-hosted runner.
使用的工具与工作流配置
我使用machulav/ec2-github-runner工具创建EC2 GitHub运行器,工作流代码如下:
- name: Start EC2 Runner id: start-ec2-runner uses: machulav/ec2-github-runner@v2 with: mode: start github-token: ${{ secrets.PAT_CLASSIC }} ec2-image-id: ${{ secrets.EC2_IMAGE_ID }} ec2-instance-type: m5a.xlarge subnet-id: ${{ secrets.EC2_SUBNET_ID }} security-group-id: ${{ secrets.EC2_SECURITY_GROUP_ID }}
IAM角色策略配置
{ "Version": "2012-10-17", "Statement": [ { "Sid": "EC2Permissions", "Effect": "Allow", "Action": [ "ec2:DescribeInstances", "ec2:RunInstances", "ec2:StartInstances", "ec2:StopInstances", "ec2:TerminateInstances", "ec2:CreateTags", "tag:TagResources" ], "Resource": "*" } ] }
已完成的检查项
- 验证GitHub Secrets中的所有凭证配置正确
- AWS IAM控制台确认EC2实例启动时已使用指定IAM角色
- EC2实例的AMI ID、子网ID、安全组ID配置无误
- 安全组已允许所有出站流量
- 重新生成仓库级自托管运行器PAT Token,并授予以下权限:
read-public key workflow repo read-repo hook
请问我还遗漏了哪些配置或检查项?
内容的提问来源于stack exchange,提问作者Navidk
相关产品推荐
相关产品推荐

