2021-01-27 19:38:34 +03:00
|
|
|
# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
data "template_file" "vsts-agent-ubuntu_20_04-startup" {
|
2021-02-08 20:25:04 +03:00
|
|
|
template = file("${path.module}/vsts_agent_ubuntu_20_04_startup.sh")
|
2021-01-27 19:38:34 +03:00
|
|
|
|
|
|
|
vars = {
|
2021-02-08 20:25:04 +03:00
|
|
|
vsts_token = secret_resource.vsts-token.value
|
2021-01-27 19:38:34 +03:00
|
|
|
vsts_account = "digitalasset"
|
|
|
|
vsts_pool = "ubuntu_20_04"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "google_compute_region_instance_group_manager" "vsts-agent-ubuntu_20_04" {
|
2021-02-08 20:25:04 +03:00
|
|
|
provider = google-beta
|
2021-01-27 19:38:34 +03:00
|
|
|
name = "vsts-agent-ubuntu-20-04"
|
|
|
|
base_instance_name = "vsts-agent-ubuntu-20-04"
|
|
|
|
region = "us-east1"
|
2021-04-29 19:17:10 +03:00
|
|
|
target_size = 20
|
2021-01-27 19:38:34 +03:00
|
|
|
|
|
|
|
version {
|
|
|
|
name = "vsts-agent-ubuntu-20-04"
|
2021-02-08 20:25:04 +03:00
|
|
|
instance_template = google_compute_instance_template.vsts-agent-ubuntu_20_04.self_link
|
2021-01-27 19:38:34 +03:00
|
|
|
}
|
|
|
|
|
2021-06-22 11:43:08 +03:00
|
|
|
# uncomment when we get a provider >3.55
|
|
|
|
#distribution_policy_target_shape = "ANY"
|
|
|
|
|
2021-01-27 19:38:34 +03:00
|
|
|
update_policy {
|
|
|
|
type = "PROACTIVE"
|
|
|
|
minimal_action = "REPLACE"
|
|
|
|
max_surge_fixed = 3
|
|
|
|
min_ready_sec = 60
|
2021-06-22 11:43:08 +03:00
|
|
|
|
|
|
|
instance_redistribution_type = "NONE"
|
2021-01-27 19:38:34 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "google_compute_instance_template" "vsts-agent-ubuntu_20_04" {
|
|
|
|
name_prefix = "vsts-agent-ubuntu-20-04-"
|
|
|
|
machine_type = "c2-standard-8"
|
2021-02-08 20:25:04 +03:00
|
|
|
labels = local.machine-labels
|
2021-01-27 19:38:34 +03:00
|
|
|
|
|
|
|
disk {
|
|
|
|
disk_size_gb = 200
|
|
|
|
disk_type = "pd-ssd"
|
|
|
|
source_image = "ubuntu-os-cloud/ubuntu-2004-lts"
|
|
|
|
}
|
|
|
|
|
|
|
|
lifecycle {
|
|
|
|
create_before_destroy = true
|
|
|
|
}
|
|
|
|
|
2021-02-08 20:25:04 +03:00
|
|
|
metadata = {
|
|
|
|
startup-script = data.template_file.vsts-agent-ubuntu_20_04-startup.rendered
|
2021-01-27 19:38:34 +03:00
|
|
|
|
2021-02-08 20:25:04 +03:00
|
|
|
shutdown-script = "#!/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 "
|
2021-01-27 19:38:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|