diff --git a/modules/vm/main.tf b/modules/vm/main.tf index 6a0e073..9ea281f 100644 --- a/modules/vm/main.tf +++ b/modules/vm/main.tf @@ -1,3 +1,21 @@ +data "template_file" "startup_script" { + template = <<-EOF + sudo apt-get update -y + curl -LO https://dl.k8s.io/release/v1.28.3/bin/linux/amd64/kubectl + echo "$(cat kubectl.sha256) kubectl" | sha256sum --check + sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl + chmod +x kubectl + mkdir -p ~/.local/bin + mv ./kubectl ~/.local/bin/kubectl + kubectl version --client + + curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 + chmod 700 get_helm.sh + ./get_helm.sh + helm version + EOF +} + resource "google_compute_instance" "vm" { name = var.vm_name machine_type = var.machine_type @@ -15,6 +33,8 @@ resource "google_compute_instance" "vm" { tags = ["bastion"] + metadata_startup_script = data.template_file.startup_script.rendered + network_interface { subnetwork = var.subnet_name access_config {