Project Icon

terraform-aws-github-runner

自动扩展GitHub Actions自托管运行器的Terraform模块

这个Terraform模块在AWS Spot实例上创建自动扩展的GitHub Actions自托管运行器。它使用AWS Lambda函数管理扩展和缩减,无活动时缩减至零以优化成本。模块支持Linux和Windows,允许自定义配置,兼容GitHub云和企业版。

Terraform module Self-Hosted Scalable GitHub Actions runners on AWS.

docs awesome-runners Terraform registry Terraform checks Lambdas

📄 Extensive documentation is available via our GitHub Pages Docs site.

📢 We maintain the project as a truly open-source project. We maintain the project on a best effort basis. We welcome contributions from the community. Feel free to help us answering issues, reviewing PRs, or maintaining and improving the project.

📢 v5 replaces Amazon Linux 2 with Amazon Linux 2023 as default OS. Check the PR for more details and other changes.

📢 For contributions to older versions you can make a PR to the related branch, e.g. v4. We have no release process in place for older versions.

This Terraform module creates the required infrastructure needed to host GitHub Actions self-hosted, auto-scaling runners on AWS spot instances. It provides the required logic to handle the life cycle for scaling up and down using a set of AWS Lambda functions. Runners are scaled down to zero to avoid costs when no workflows are active.

Runners overview

Features

  • Scaling: Scale up and down based on GitHub events
  • Sustainability: Scale down to zero when no jobs are running
  • Security: Runners are created on-demand and terminated after use (ephemeral runners)
  • Cost optimization: Runners are created on spot instances
  • Tailored software, hardware and network configuration: Bring your own AMI, define the instance types and subnets to use.
  • OS support: Linux (x64/arm64) and Windows
  • Multi-Runner: Create multiple runner configurations with a single deployment
  • GitHub cloud and GitHub Enterprise Server (GHES) support.
  • Org and repo level runners. enterprise level runners are not supported (yet).

Getting started

Check out the detailed instructions in the Getting Started section of the docs. On a high level, the following steps are required to get started:

  • Setup your AWS account
  • Create and configure a GitHub App
  • Download or build the required lambdas
  • Deploy the module using Terraform
  • Install the GitHub App to your organization or repositories and add your repositories to the runner group(s).

Check out the provided Terraform examples in the examples directory for different scenarios.

Configuration

Please check the configuration section of the docs for major configuration options. See the Terraform module documentation for all available options.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

We welcome contributions, please check out the contribution guide. Be aware we use pre commit hooks to update the docs.

Philips Forest

This module is part of the Philips Forest.

                                                     ___                   _
                                                    / __\__  _ __ ___  ___| |_
                                                   / _\/ _ \| '__/ _ \/ __| __|
                                                  / / | (_) | | |  __/\__ \ |_
                                                  \/   \___/|_|  \___||___/\__|

                                                                 Infrastructure

Talk to the forestkeepers in the runners-channel on Slack.

Slack

Terraform root module documention

Requirements

NameVersion
terraform>= 1.3.0
aws~> 5.27
random~> 3.0

Providers

NameVersion
aws5.31.0
random3.6.0

Modules

NameSourceVersion
ami_housekeeper./modules/ami-housekeepern/a
instance_termination_watcher./modules/termination-watchern/a
runner_binaries./modules/runner-binaries-syncern/a
runners./modules/runnersn/a
ssm./modules/ssmn/a
webhook./modules/webhookn/a

Resources

Inputs

NameDescriptionTypeDefaultRequired
ami_filterMap of lists used to create the AMI filter for the action runner AMI.map(list(string))
{
"state": [
"available"
]
}
no
ami_housekeeper_cleanup_configConfiguration for AMI cleanup.

amiFilters - Filters to use when searching for AMIs to cleanup. Default filter for images owned by the account and that are available.
dryRun - If true, no AMIs will be deregistered. Default false.
launchTemplateNames - Launch template names to use when searching for AMIs to cleanup. Default no launch templates.
maxItems - The maximum numer of AMI's tha will be queried for cleanup. Default no maximum.
minimumDaysOld - Minimum number of days old an AMI must be to be considered for cleanup. Default 30.
ssmParameterNames - SSM parameter names to use when searching for AMIs to cleanup. This parameter should be set when using SSM to configure the AMI to use. Default no SSM parameters.
object({
amiFilters = optional(list(object({
Name = string
Values = list(string)
})),
[{
Name : "state",
Values : ["available"],
},
{
Name : "image-type",
Values : ["machine"],
}]
)
dryRun = optional(bool, false)
launchTemplateNames = optional(list(string))
maxItems = optional(number)
minimumDaysOld = optional(number, 30)
ssmParameterNames = optional(list(string))
})
{}no
ami_housekeeper_lambda_s3_keyS3 key for syncer lambda function. Required if using S3 bucket to specify lambdas.stringnullno
ami_housekeeper_lambda_s3_object_versionS3 object version for syncer lambda function. Useful if S3 versioning is enabled on source bucket.stringnullno
ami_housekeeper_lambda_schedule_expressionScheduler expression for action runner binary syncer.string"rate(1 day)"no
ami_housekeeper_lambda_timeoutTime out of the lambda in seconds.number300no
ami_housekeeper_lambda_zipFile location of the lambda zip file.stringnullno
ami_id_ssm_parameter_nameExternally managed SSM parameter (of data type aws:ec2:image) that contains the AMI ID to launch runner instances from. Overrides ami_filterstringnullno
ami_kms_key_arnOptional CMK Key ARN to be used to launch an instance from a shared encrypted AMIstringnullno
ami_ownersThe list of owners used to select the AMI of action runner instances.list(string)
[
"amazon"
]
no
associate_public_ipv4_addressAssociate public IPv4 with the runner. Only tested with IPv4boolfalseno
aws_partition(optiona) partition in the arn namespace to use if not 'aws'string"aws"no
aws_regionAWS region.stringn/ayes
block_device_mappingsThe EC2 instance block device configuration. Takes the following keys: device_name, delete_on_termination, volume_type, volume_size, encrypted, iops, throughput, kms_key_id, snapshot_id.
list(object({
delete_on_termination = optional(bool, true)
device_name = optional(string, "/dev/xvda")
encrypted = optional(bool, true)
iops = optional(number)
kms_key_id = optional(string)
snapshot_id = optional(string)
throughput = optional(number)
volume_size = number
volume_type = optional(string, "gp3")
}))
[
{
"volume_size": 30
}
]
no
cloudwatch_config(optional) Replaces the module's default cloudwatch log config. See https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html for details.stringnullno
create_service_linked_role_spot(optional) create the service linked role for spot instances that is required by the scale-up lambda.boolfalseno
delay_webhook_eventThe number of seconds the event accepted by the webhook is invisible on the queue before the scale up lambda will receive the event.number30no
disable_runner_autoupdateDisable the auto update of the github runner agent. Be aware there is a grace period of 30 days, see also the GitHub articleboolfalseno
enable_ami_housekeeperOption to disable the lambda to clean up old AMIs.boolfalseno
enable_cloudwatch_agentEnables the cloudwatch agent on the ec2 runner instances. The runner uses a default config that can be overridden via cloudwatch_config.booltrueno
enable_ephemeral_runnersEnable ephemeral runners, runners will only be used once.boolfalseno
enable_event_rule_binaries_syncerDEPRECATED: Replaced by state_event_rule_binaries_syncer.boolnullno
enable_fifo_build_queueEnable a FIFO queue to keep the order of events received by the webhook. Recommended for repo level runners.boolfalseno
项目侧边栏1项目侧边栏2
推荐项目
Project Cover

豆包MarsCode

豆包 MarsCode 是一款革命性的编程助手,通过AI技术提供代码补全、单测生成、代码解释和智能问答等功能,支持100+编程语言,与主流编辑器无缝集成,显著提升开发效率和代码质量。

Project Cover

AI写歌

Suno AI是一个革命性的AI音乐创作平台,能在短短30秒内帮助用户创作出一首完整的歌曲。无论是寻找创作灵感还是需要快速制作音乐,Suno AI都是音乐爱好者和专业人士的理想选择。

Project Cover

有言AI

有言平台提供一站式AIGC视频创作解决方案,通过智能技术简化视频制作流程。无论是企业宣传还是个人分享,有言都能帮助用户快速、轻松地制作出专业级别的视频内容。

Project Cover

Kimi

Kimi AI助手提供多语言对话支持,能够阅读和理解用户上传的文件内容,解析网页信息,并结合搜索结果为用户提供详尽的答案。无论是日常咨询还是专业问题,Kimi都能以友好、专业的方式提供帮助。

Project Cover

阿里绘蛙

绘蛙是阿里巴巴集团推出的革命性AI电商营销平台。利用尖端人工智能技术,为商家提供一键生成商品图和营销文案的服务,显著提升内容创作效率和营销效果。适用于淘宝、天猫等电商平台,让商品第一时间被种草。

Project Cover

吐司

探索Tensor.Art平台的独特AI模型,免费访问各种图像生成与AI训练工具,从Stable Diffusion等基础模型开始,轻松实现创新图像生成。体验前沿的AI技术,推动个人和企业的创新发展。

Project Cover

SubCat字幕猫

SubCat字幕猫APP是一款创新的视频播放器,它将改变您观看视频的方式!SubCat结合了先进的人工智能技术,为您提供即时视频字幕翻译,无论是本地视频还是网络流媒体,让您轻松享受各种语言的内容。

Project Cover

美间AI

美间AI创意设计平台,利用前沿AI技术,为设计师和营销人员提供一站式设计解决方案。从智能海报到3D效果图,再到文案生成,美间让创意设计更简单、更高效。

Project Cover

稿定AI

稿定设计 是一个多功能的在线设计和创意平台,提供广泛的设计工具和资源,以满足不同用户的需求。从专业的图形设计师到普通用户,无论是进行图片处理、智能抠图、H5页面制作还是视频剪辑,稿定设计都能提供简单、高效的解决方案。该平台以其用户友好的界面和强大的功能集合,帮助用户轻松实现创意设计。

投诉举报邮箱: service@vectorlightyear.com
@2024 懂AI·鲁ICP备2024100362号-6·鲁公网安备37021002001498号