-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.tf
50 lines (40 loc) · 1.35 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.27"
}
}
required_version = ">= 0.14.9"
}
provider "aws" {
profile = "default"
region = "eu-west-2"
}
data "aws_availability_zones" "all_azs" {
state = "available"
}
resource "aws_launch_template" "ec2_launch_template" {
name = "github_runner_launch_template"
description = "Launch Template for GitHub Runners EC2 AutoScaling Group"
image_id = var.ami
instance_type = var.instance_type
key_name = var.key_name
user_data = base64encode(templatefile("${path.cwd}/bootstrap.tmpl", { github_repo_url = var.github_repo_url, github_repo_pat_token = var.github_repo_pat_token, runner_name = var.runner_name, labels = join(",", var.labels) }))
tags = {
Name = "github_runner"
}
}
resource "aws_autoscaling_group" "github_runners_autoscaling_group" {
name = "github_runners_autoscaling_group"
availability_zones = data.aws_availability_zones.all_azs.names
health_check_type = "EC2"
health_check_grace_period = var.health_check_grace_period
desired_capacity = var.desired_capacity
min_size = var.min_size
max_size = var.max_size
launch_template {
id = aws_launch_template.ec2_launch_template.id
version = "$Latest"
}
}