forked from digital-asset/daml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvsts_agent_ubuntu_20_04.tf
95 lines (78 loc) · 2.57 KB
/
vsts_agent_ubuntu_20_04.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
locals {
ubuntu = [
{
name = "ci-u1",
disk_size = 200,
size = 30,
},
{
name = "ci-u2",
disk_size = 400,
size = 0,
},
]
}
data "template_file" "vsts-agent-ubuntu_20_04-startup" {
count = length(local.ubuntu)
template = file("${path.module}/vsts_agent_ubuntu_20_04_startup.sh")
vars = {
vsts_token = secret_resource.vsts-token.value
vsts_account = "digitalasset"
vsts_pool = "ubuntu_20_04"
}
}
resource "google_compute_region_instance_group_manager" "vsts-agent-ubuntu_20_04" {
count = length(local.ubuntu)
provider = google-beta
name = local.ubuntu[count.index].name
base_instance_name = local.ubuntu[count.index].name
region = "us-east1"
target_size = local.ubuntu[count.index].size
version {
name = local.ubuntu[count.index].name
instance_template = google_compute_instance_template.vsts-agent-ubuntu_20_04[count.index].self_link
}
# uncomment when we get a provider >3.55
#distribution_policy_target_shape = "ANY"
update_policy {
type = "PROACTIVE"
minimal_action = "REPLACE"
max_surge_fixed = 3
min_ready_sec = 60
instance_redistribution_type = "NONE"
}
}
resource "google_compute_instance_template" "vsts-agent-ubuntu_20_04" {
count = length(local.ubuntu)
name_prefix = "${local.ubuntu[count.index].name}-"
machine_type = "c2-standard-8"
labels = local.machine-labels
disk {
disk_size_gb = local.ubuntu[count.index].disk_size
disk_type = "pd-ssd"
source_image = "ubuntu-os-cloud/ubuntu-2004-lts"
}
lifecycle {
create_before_destroy = true
}
metadata = {
startup-script = data.template_file.vsts-agent-ubuntu_20_04-startup[count.index].rendered
shutdown-script = nonsensitive("#!/usr/bin/env bash\nset -euo pipefail\ncd /home/vsts/agent\nsu vsts <<SHUTDOWN_AGENT\nexport VSTS_AGENT_INPUT_TOKEN='${secret_resource.vsts-token.value}'\n./config.sh remove --unattended --auth PAT\nSHUTDOWN_AGENT\n ")
}
network_interface {
network = "default"
// Ephemeral IP to get access to the Internet
access_config {}
}
service_account {
email = "log-writer@da-dev-gcp-daml-language.iam.gserviceaccount.com"
scopes = ["cloud-platform"]
}
scheduling {
automatic_restart = false
on_host_maintenance = "TERMINATE"
preemptible = false
}
}