waylew-lexis / terraform-azurerm-github-runner

terraform-azurerm-github-runner

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GitHub Runner Azure Virtual Machine

This Terraform module will create a self-hosted GitHub runner hosted on an Azure VM. The module will configure a Managed Identity for the VM. See examples for recommended terraform implementation.

Features

  • Supports Linux or Windows os runner type.
  • Assigns a managed identity to allow access to Azure API.
  • Supports repository or organization scoped runners.
  • Both images install the following: Azure CLI, Terraform, and Git.

Runner Tokens

In order for the runner to access GitHub resources, the module requires supplying a runner token.

Repository Scoped

You can add self-hosted runners to a single repository. To add a self-hosted runner to a user repository, you must be the repository owner. For an organization repository, you must be an organization owner or have admin access to the repository.

  1. To generate a repository scoped runner token, from the repository go to Settings > Actions > Self-hosted runners section, clicking on “Add runner” button. Look for the token in the configuration steps:
        $ ./config.cmd --url https://github.com/LexisNexis-RBA/terraform-azure-vm-github-runner --token {RUNNER_TOKEN} Run it!
        $ ./run.cmd
    
  2. Copy the token value. This will be used for the 'github_runner_token' variable.

Organization Scoped

You can add self-hosted runners at the organization level, where they can be used to process jobs for multiple repositories in an organization. To add a self-hosted runner to an organization, you must be an organization owner.

Requirements

Name Version
azurerm >= 2.72, < 3.0
null >= 3.0.0
tls >= 3.1.0

Providers

Name Version
azurerm >= 2.72, < 3.0
random n/a
template n/a
tls >= 3.1.0

Modules

No modules.

Resources

Name Type
azurerm_linux_virtual_machine.vm resource
azurerm_network_interface.dynamic resource
azurerm_virtual_machine_extension.ext resource
azurerm_windows_virtual_machine.vm resource
random_password.password resource
tls_private_key.ssh_key resource
template_file.linux_script data source

Inputs

Name Description Type Default Required
admin_password the admin password. leave blank to assign a random password string null no
admin_username the admin user string "adminuser" no
custom_ubuntu_image_id the custom vm image to use string null no
diagnostics_storage_account_uri The Endpoint for the Azure Storage Account which should be used to store Boot Diagnostics, including Console Output and Screenshots from the Hypervisor. string null no
enable_boot_diagnostics Whether to enable boot diagnostics on the runner which enables the serial console bool false no
github_org_name The GitHub organization. string n/a yes
github_repo_name The GitHub repository. string null no
github_runner_token The GitHub runner token. string n/a yes
identity_ids Specifies a list of user assigned managed identity ids to be assigned to the VM. list(string) [] no
identity_type The Managed Service Identity Type of this Virtual Machine. Possible values are SystemAssigned (where Azure will generate a Service Principal for you), UserAssigned (where you can specify the Service Principal ID's). string "SystemAssigned" no
location Azure region string n/a yes
name The name of the created resources. string n/a yes
resource_group_name Resource group name string n/a yes
runner_group the group this runner belongs to. required if runner-scope is "org" string "" no
runner_labels list of labels to associate to the runner list(string) n/a yes
runner_os The runner operating system. Allowed values are "linux" or "windows" string "linux" no
runner_scope The scope of the runner. Choices are "Org" or "Repo". string "repo" no
subnet_id Virtual network subnet ID string n/a yes
tags Tags to be applied to resources map(string) {} no
ubuntu_source_image_reference The linux Ubuntu publisher image to use.
object({
publisher = string
offer = string
sku = string
version = string
})
{
"offer": "0001-com-ubuntu-server-focal",
"publisher": "Canonical",
"sku": "20_04-lts-gen2",
"version": "latest"
}
no
virtual_machine_size Virtual machine instance size string "Standard_D2s_v4" no
win_computer_name The windows computer name. string null no
windows_source_image_reference The Windows publisher image to use.
object({
publisher = string
offer = string
sku = string
version = string
})
{
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2019-Datacenter",
"version": "latest"
}
no

Outputs

Name Description
computer_name The virtual machine and github runner name
principal_id The principal id of the managed identity
private_ip Private IP Address of the virtual machine

About

terraform-azurerm-github-runner

License:Apache License 2.0


Languages

Language:HCL 69.5%Language:Shell 22.8%Language:PowerShell 7.7%