terraform-aws-github-runner

terraform-aws-github-runner

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

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

GitHub ActionsAWSTerraform自托管运行器基础设施即代码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.

<picture> <source media="(prefers-color-scheme: dark)" srcset="docs/assets/runners.dark.png"> <source media="(prefers-color-scheme: light)" srcset="docs/assets/runners.light.png"> <img alt="Runners overview" src="docs/assets/runners.light.png"> </picture>

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

<details> <summary>Terraform root module documention</summary> <!-- --8<-- [start:mkdocsrunners] --> <!-- BEGIN_TF_DOCS -->

Requirements

NameVersion
<a name="requirement_terraform"></a> terraform>= 1.3.0
<a name="requirement_aws"></a> aws~> 5.27
<a name="requirement_random"></a> random~> 3.0

Providers

NameVersion
<a name="provider_aws"></a> aws5.31.0
<a name="provider_random"></a> random3.6.0

Modules

NameSourceVersion
<a name="module_ami_housekeeper"></a> ami_housekeeper./modules/ami-housekeepern/a
<a name="module_instance_termination_watcher"></a> instance_termination_watcher./modules/termination-watchern/a
<a name="module_runner_binaries"></a> runner_binaries./modules/runner-binaries-syncern/a
<a name="module_runners"></a> runners./modules/runnersn/a
<a name="module_ssm"></a> ssm./modules/ssmn/a
<a name="module_webhook"></a> webhook./modules/webhookn/a

Resources

NameType
aws_sqs_queue.queued_buildsresource
aws_sqs_queue.queued_builds_dlqresource
aws_sqs_queue.webhook_events_workflow_job_queueresource
aws_sqs_queue_policy.build_queue_dlq_policyresource
aws_sqs_queue_policy.build_queue_policyresource
aws_sqs_queue_policy.webhook_events_workflow_job_queue_policyresource
random_string.randomresource
aws_iam_policy_document.deny_unsecure_transportdata source

Inputs

NameDescriptionTypeDefaultRequired
<a name="input_ami_filter"></a> ami_filterMap of lists used to create the AMI filter for the action runner AMI.map(list(string))<pre>{<br> "state": [<br> "available"<br> ]<br>}</pre>no
<a name="input_ami_housekeeper_cleanup_config"></a> ami_housekeeper_cleanup_configConfiguration for AMI cleanup.<br><br> amiFilters - Filters to use when searching for AMIs to cleanup. Default filter for images owned by the account and that are available.<br> dryRun - If true, no AMIs will be deregistered. Default false.<br> launchTemplateNames - Launch template names to use when searching for AMIs to cleanup. Default no launch templates.<br> maxItems - The maximum numer of AMI's tha will be queried for cleanup. Default no maximum.<br> minimumDaysOld - Minimum number of days old an AMI must be to be considered for cleanup. Default 30.<br> 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.<pre>object({<br> amiFilters = optional(list(object({<br> Name = string<br> Values = list(string)<br> })),<br> [{<br> Name : "state",<br> Values : ["available"],<br> },<br> {<br> Name : "image-type",<br> Values : ["machine"],<br> }]<br> )<br> dryRun = optional(bool, false)<br> launchTemplateNames = optional(list(string))<br> maxItems = optional(number)<br> minimumDaysOld = optional(number, 30)<br> ssmParameterNames = optional(list(string))<br> })</pre>{}no
<a name="input_ami_housekeeper_lambda_s3_key"></a> ami_housekeeper_lambda_s3_keyS3 key for syncer lambda function. Required if using S3 bucket to specify lambdas.stringnullno
<a name="input_ami_housekeeper_lambda_s3_object_version"></a> ami_housekeeper_lambda_s3_object_versionS3 object version for syncer lambda function. Useful if S3 versioning is enabled on source bucket.stringnullno
<a name="input_ami_housekeeper_lambda_schedule_expression"></a> ami_housekeeper_lambda_schedule_expressionScheduler expression for action runner binary syncer.string"rate(1 day)"no
<a name="input_ami_housekeeper_lambda_timeout"></a> ami_housekeeper_lambda_timeoutTime out of the lambda in seconds.number300no
<a name="input_ami_housekeeper_lambda_zip"></a> ami_housekeeper_lambda_zipFile location of the lambda zip file.stringnullno
<a name="input_ami_id_ssm_parameter_name"></a> 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
<a name="input_ami_kms_key_arn"></a> ami_kms_key_arnOptional CMK Key ARN to be used to launch an instance from a shared encrypted AMIstringnullno
<a name="input_ami_owners"></a> ami_ownersThe list of owners used to select the AMI of action runner instances.list(string)<pre>[<br> "amazon"<br>]</pre>no
<a name="input_associate_public_ipv4_address"></a> associate_public_ipv4_addressAssociate public IPv4 with the runner. Only tested with IPv4boolfalseno
<a name="input_aws_partition"></a> aws_partition(optiona) partition in the arn namespace to use if not 'aws'string"aws"no
<a name="input_aws_region"></a> aws_regionAWS region.stringn/ayes
<a name="input_block_device_mappings"></a> 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.<pre>list(object({<br> delete_on_termination = optional(bool, true)<br> device_name = optional(string, "/dev/xvda")<br> encrypted = optional(bool, true)<br> iops = optional(number)<br> kms_key_id = optional(string)<br> snapshot_id = optional(string)<br> throughput = optional(number)<br> volume_size = number<br> volume_type = optional(string, "gp3")<br> }))</pre><pre>[<br> {<br> "volume_size": 30<br> }<br>]</pre>no
<a name="input_cloudwatch_config"></a> 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
<a name="input_create_service_linked_role_spot"></a> create_service_linked_role_spot(optional) create the service linked role for spot instances that is required by the scale-up lambda.boolfalseno
<a name="input_delay_webhook_event"></a> 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
<a name="input_disable_runner_autoupdate"></a> 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
<a name="input_enable_ami_housekeeper"></a> enable_ami_housekeeperOption to disable the lambda to clean up old AMIs.boolfalseno
<a name="input_enable_cloudwatch_agent"></a> 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
<a name="input_enable_ephemeral_runners"></a> enable_ephemeral_runnersEnable ephemeral runners, runners will only be used once.boolfalseno
<a name="input_enable_event_rule_binaries_syncer"></a> enable_event_rule_binaries_syncerDEPRECATED: Replaced by state_event_rule_binaries_syncer.boolnullno
<a name="input_enable_fifo_build_queue"></a> enable_fifo_build_queueEnable a FIFO queue to keep the order of events received by the webhook. Recommended for repo level runners.boolfalseno
<a name="input_enable_jit_config"></a>

编辑推荐精选

TRAE编程

TRAE编程

AI辅助编程,代码自动修复

Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

AI工具TraeAI IDE协作生产力转型热门
蛙蛙写作

蛙蛙写作

AI小说写作助手,一站式润色、改写、扩写

蛙蛙写作—国内先进的AI写作平台,涵盖小说、学术、社交媒体等多场景。提供续写、改写、润色等功能,助力创作者高效优化写作流程。界面简洁,功能全面,适合各类写作者提升内容品质和工作效率。

AI辅助写作AI工具蛙蛙写作AI写作工具学术助手办公助手营销助手AI助手
问小白

问小白

全能AI智能助手,随时解答生活与工作的多样问题

问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。

热门AI助手AI对话AI工具聊天机器人
Transly

Transly

实时语音翻译/同声传译工具

Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。

讯飞智文

讯飞智文

一键生成PPT和Word,让学习生活更轻松

讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。

AI办公办公工具AI工具讯飞智文AI在线生成PPTAI撰写助手多语种文档生成AI自动配图热门
讯飞星火

讯飞星火

深度推理能力全新升级,全面对标OpenAI o1

科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。

热门AI开发模型训练AI工具讯飞星火大模型智能问答内容创作多语种支持智慧生活
Spark-TTS

Spark-TTS

一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型

Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。

咔片PPT

咔片PPT

AI助力,做PPT更简单!

咔片是一款轻量化在线演示设计工具,借助 AI 技术,实现从内容生成到智能设计的一站式 PPT 制作服务。支持多种文档格式导入生成 PPT,提供海量模板、智能美化、素材替换等功能,适用于销售、教师、学生等各类人群,能高效制作出高品质 PPT,满足不同场景演示需求。

讯飞绘文

讯飞绘文

选题、配图、成文,一站式创作,让内容运营更高效

讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加速品牌传播,提升内容营销效果。

热门AI辅助写作AI工具讯飞绘文内容运营AI创作个性化文章多平台分发AI助手
材料星

材料星

专业的AI公文写作平台,公文写作神器

AI 材料星,专业的 AI 公文写作辅助平台,为体制内工作人员提供高效的公文写作解决方案。拥有海量公文文库、9 大核心 AI 功能,支持 30 + 文稿类型生成,助力快速完成领导讲话、工作总结、述职报告等材料,提升办公效率,是体制打工人的得力写作神器。

下拉加载更多