Skip to content

Commit

Permalink
metadata cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Pouliot committed May 20, 2024
1 parent 5bfd2d7 commit 6daa048
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 60 deletions.
29 changes: 27 additions & 2 deletions images.tf
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
# Azure Aarch64 Images
locals {
os_images = {
rockylinux8 = {
os_image = "rocky-linux-8-optimized-gcp-arm64"
default_os_user = "rockylinux"
startup_script = file("${local.startup_script_template_file}")
}
rockylinux9 = {
os_image = "rocky-linux-9-arm64"
default_os_user = "rockylinux"
startup_script = data.template_file.startup_script.rendered
startup_script = file("${local.startup_script_template_file}")
}
debian11 = {
os_image = "debian-11-arm64"
default_os_user = "debian"
startup_script = data.template_file.startup_script.rendered
startup_script = file("${local.startup_script_template_file}")
}
debian12 = {
os_image = "debian-12-arm64"
default_os_user = "debian"
startup_script = file("${local.startup_script_template_file}")
}
fedoracoreos = {
os_image = "fedora-coreos-stable-arm64"
default_os_user = "fedora"
startup_script = null
}
ubuntu1804 = {
os_image = "ubuntu-1804-lts-arm64"
Expand All @@ -26,5 +41,15 @@ locals {
default_os_user = "ubuntu"
startup_script = null
}
ubuntu2404 = {
os_image = "ubuntu-2404-lts-arm64"
default_os_user = "ubuntu"
startup_script = null
}
sles15 = {
os_image = "sles-15-arm64"
default_os_user = "suse"
startup_script = null
}
}
}
17 changes: 17 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@

# Cloud-Init file
locals {
# return var.cloud_init_template_path if it's not null
# otherwise return "${path.module}/templates/cloud-init.yaml.tpl"
cloud_init_template_file = coalesce(var.cloud_init_template_file, "${path.module}/templates/cloud-init.yaml.tpl")
startup_script_template_file = coalesce(var.startup_script_template_file, "${path.module}/templates/startup-script.sh.tpl")
}

# ssh keys
resource "tls_private_key" "gcp" {
algorithm = "RSA"
Expand Down Expand Up @@ -34,3 +43,11 @@ output "random_uuid" {
value = random_uuid.random_id.result
sensitive = false
}

resource "google_os_login_ssh_public_key" "cache" {
user = data.google_client_openid_userinfo.me.email
# key = tls_private_key.gcp.public_key_openssh
key = "${replace(tls_private_key.gcp.public_key_openssh, "\n", "")} ${split("@", data.google_client_openid_userinfo.me.email)[0]}"
project = var.project_id
}

55 changes: 0 additions & 55 deletions metadata.tf

This file was deleted.

4 changes: 2 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ variable "gcp_vcn_cidr_subnet" {
}

variable "gcp_os_image" {
# default = "ubuntu2204"
default = "ubuntu2404"
# default = "rockylinux9"
default = "debian11"
# default = "debian11"
description = "Default OS Image From the Local Vars"
}
4 changes: 3 additions & 1 deletion virtual_machine.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ resource "google_compute_instance" "default" {
metadata = {
enable-oslogin = true
ssh-keys = "${split("@", data.google_client_openid_userinfo.me.email)[0]}:${replace(tls_private_key.gcp.public_key_openssh, "\n", "")} ${split("@", data.google_client_openid_userinfo.me.email)[0]}"
user-data = data.template_file.cloud_config.rendered
# user-data = data.template_file.cloud_config.rendered
# user_data = "${base64encode(file("${local.cloud_init_template_file}"))}"
user_data = "${file("${local.cloud_init_template_file}")}"
startup-script = local.os_images[var.gcp_os_image].startup_script
}
boot_disk {
Expand Down

0 comments on commit 6daa048

Please sign in to comment.