@@ -2,9 +2,12 @@ locals {
2
2
gh_owner = " datalens-tech"
3
3
gh_repo = " datalens"
4
4
5
- runner_version = " 2.319.1 "
5
+ runner_ssh_access = false
6
6
7
- runners_count = 1
7
+ runner_os_image = " ubuntu-2404-lts-oslogin"
8
+ runner_version = " 2.319.1"
9
+
10
+ runners_count = 2
8
11
runners_ids = local. is_create_github_runner ? [for i in range (0 , local. runners_count ) : { key = " ind-${ i } " , ind = i }] : []
9
12
}
10
13
@@ -14,12 +17,6 @@ resource "yandex_lockbox_secret" "github-runner" {
14
17
name = " ${ local . service } -github-runner-secrets"
15
18
}
16
19
17
- data "yandex_lockbox_secret_version" "github-runner" {
18
- for_each = toset (local. is_create_github_runner ? [" main" ] : [])
19
-
20
- secret_id = yandex_lockbox_secret. github-runner [" main" ]. id
21
- }
22
-
23
20
resource "yandex_iam_service_account" "github-runner" {
24
21
for_each = toset (local. is_create_github_runner ? [" main" ] : [])
25
22
@@ -34,8 +31,29 @@ resource "yandex_resourcemanager_folder_iam_member" "github-runner" {
34
31
member = " serviceAccount:${ yandex_iam_service_account . github-runner [" main" ]. id } "
35
32
}
36
33
34
+ resource "yandex_lockbox_secret_iam_binding" "github-runner" {
35
+ for_each = toset (local. is_create_github_runner ? [" main" ] : [])
36
+
37
+ secret_id = yandex_lockbox_secret. github-runner [" main" ]. id
38
+ role = " lockbox.payloadViewer"
39
+
40
+ members = [
41
+ " serviceAccount:${ yandex_iam_service_account . github-runner [" main" ]. id } " ,
42
+ ]
43
+ }
44
+
37
45
data "yandex_compute_image" "this" {
38
- family = " ubuntu-24-04-lts"
46
+ family = local. runner_os_image
47
+ }
48
+
49
+ resource "yandex_vpc_address" "github-runner" {
50
+ for_each = local. runner_ssh_access ? { for id in local . runners_ids : id . key => id . ind } : {}
51
+
52
+ name = " github-runner-${ each . key } -ip"
53
+
54
+ external_ipv4_address {
55
+ zone_id = " ru-central1-a"
56
+ }
39
57
}
40
58
41
59
resource "yandex_compute_disk" "github-runner" {
@@ -77,10 +95,14 @@ resource "yandex_compute_instance" "github-runner" {
77
95
subnet_id = yandex_vpc_subnet. this [local . zones [each . value % length (local. zones )]]. id
78
96
security_group_ids = [yandex_vpc_security_group . github-runner [" main" ]. id ]
79
97
ipv4 = true
98
+
99
+ nat = local. runner_ssh_access
100
+ nat_ip_address = local. runner_ssh_access ? yandex_vpc_address. github-runner [each . key ]. external_ipv4_address [0 ]. address : null
80
101
}
81
102
82
103
metadata = {
83
104
skip_update_ssh_keys = true
105
+ enable-oslogin = true
84
106
85
107
user-data = templatefile (" github-runner-config.yaml" , {
86
108
VERSION = local.runner_version
@@ -89,7 +111,8 @@ resource "yandex_compute_instance" "github-runner" {
89
111
REPO = local.gh_repo
90
112
IND = " ${ each . value } "
91
113
92
- TOKEN = [for secret in data . yandex_lockbox_secret_version . github-runner [" main" ]. entries : secret . text_value if secret . key == " RUNNER_${ upper (replace (local. gh_repo , " -" , " _" ))} _${ each . value } _TOKEN" ][0 ]
114
+ LOCKBOX_ID = yandex_lockbox_secret.github- runner[" main" ].id
115
+ LOCKBOX_KEY = " RUNNER_${ upper (replace (local. gh_repo , " -" , " _" ))} _${ each . value } _TOKEN"
93
116
})
94
117
}
95
118
}
@@ -130,11 +153,11 @@ data "dns_a_record_set" "github-runner-gh" {
130
153
locals {
131
154
v4_gh_any_cidr_blocks = [" 0.0.0.0/0" ]
132
155
133
- ingress_github_runner = [
156
+ ingress_github_runner = concat ( [
134
157
{ proto = " ANY" , target = " self_security_group" , from_port = 0 , to_port = 65535 , desc = " self" },
135
158
{ proto = " ANY" , cidr_v4 = local.v4_subnets_cidr_blocks, from_port = 0 , to_port = 65535 , desc = " subnets" },
136
159
{ proto = " ICMP" , cidr_v4 = local.v4_icmp_cidr_blocks, from_port = 0 , to_port = 65535 , desc = " icmp" },
137
- ]
160
+ ], local . runner_ssh_access ? [{ proto = " TCP " , cidr_v4 = [ " ${ local . v4_public_ip } /32 " ], port = 22 , desc = " ssh " }] : [])
138
161
egress_github_runner = concat (
139
162
[
140
163
{ proto = " ANY" , target = " self_security_group" , from_port = 0 , to_port = 65535 , desc = " self" },
@@ -147,7 +170,7 @@ locals {
147
170
{ proto = " TCP" , cidr_v4 = local.v4_gh_any_cidr_blocks, port = 443 , desc = " any" },
148
171
],
149
172
[for e in local . endpoints : { proto = " TCP" , cidr_v4 = [" ${ data . dns_a_record_set . this [e ]. addrs [0 ]} /32" ], port = 443 , desc = e }],
150
- [for e in local . gh_endpoints : { proto = " TCP" , cidr_v4 = [" ${ data . dns_a_record_set . github-runner-gh [e ]. addrs [0 ]} /32" ], port = 43 , desc = e }],
173
+ [for e in local . gh_endpoints : { proto = " TCP" , cidr_v4 = [" ${ data . dns_a_record_set . github-runner-gh [e ]. addrs [0 ]} /32" ], port = 443 , desc = e }],
151
174
[for e in local . common_endpoints : { proto = " TCP" , cidr_v4 = [" ${ data . dns_a_record_set . github-runner-common [e ]. addrs [0 ]} /32" ], port = 80 , desc = e }],
152
175
[for e in local . common_endpoints : { proto = " TCP" , cidr_v4 = [" ${ data . dns_a_record_set . github-runner-common [e ]. addrs [0 ]} /32" ], port = 443 , desc = e }],
153
176
)
0 commit comments