Skip to content

Commit

Permalink
silicon/design/main: add vm based notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
proppy committed Oct 18, 2022
1 parent 12eac53 commit 6fa151e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
47 changes: 45 additions & 2 deletions modules/silicon_design/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,10 @@ resource "google_project_iam_member" "ai_notebook_user_role2" {
role = "roles/viewer"
}

resource "google_notebooks_instance" "ai_notebook" {
resource "google_notebooks_instance" "ai_notebook_container" {
count = var.notebook_count
project = local.project.project_id
name = local.notebook_names[count.index]
name = "${local.notebook_names[count.index]}-container"
location = var.zone
machine_type = var.machine_type

Expand Down Expand Up @@ -305,6 +305,49 @@ resource "google_notebooks_instance" "ai_notebook" {
]
}

resource "google_notebooks_instance" "ai_notebook_vm" {
count = var.notebook_count
project = local.project.project_id
name = "${local.notebook_names[count.index]}-vm"
location = var.zone
machine_type = var.machine_type

vm_image {
project = local.project.project_id
image_name = "${var.image_name}-${local.image_tag}"
}

service_account = google_service_account.sa_p_notebook.email

install_gpu_driver = false
boot_disk_type = var.boot_disk_type
boot_disk_size_gb = var.boot_disk_size_gb
data_disk_type = var.data_disk_type
data_disk_size_gb = var.data_disk_size_gb
no_remove_data_disk = true

no_public_ip = false
no_proxy_access = false

network = local.network.self_link
subnet = local.subnet.self_link

post_startup_script = "gs://${google_storage_bucket.staging_bucket.name}/copy-notebooks.sh"

labels = {
module = "silicon-design"
}

metadata = {
terraform = "true"
proxy-mode = "service_account"
}
depends_on = [
time_sleep.wait_120_seconds,
null_resource.build_and_push_image,
]
}

resource "null_resource" "ai_notebook_provisioning_state" {
for_each = toset(google_notebooks_instance.ai_notebook[*].name)
provisioner "local-exec" {
Expand Down
2 changes: 1 addition & 1 deletion modules/silicon_design/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ output "notebook_container_image" {

output "notebook_instance_names" {
description = "Notebook Instance Names"
value = join(", ", google_notebooks_instance.ai_notebook[*].name)
value = join(", ", concat(google_notebooks_instance.ai_notebook_container[*].name, google_notebooks_instance.ai_notebook_vm[*].name))
}

output "artifact_registry_repository_id" {
Expand Down

0 comments on commit 6fa151e

Please sign in to comment.