Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions iac/provider-gcp/nomad-cluster-disk-image/Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
ENV := $(shell cat ../../../.last_used_env || echo "not-set")
-include ../../../.env.${ENV}

NETWORK_NAME := "e2b-build-cluster-disk-image"
PACKER_NETWORK_NAME ?= e2b-build-cluster-disk-image
PACKER_SUBNET_NAME ?= e2b-build-cluster-disk-image-subnetwork

tf_vars := TF_VAR_gcp_project_id=$(GCP_PROJECT_ID) \
TF_VAR_gcp_region=$(GCP_REGION) \
TF_VAR_network_name=$(NETWORK_NAME)
TF_VAR_network_name=$(PACKER_NETWORK_NAME) \
TF_VAR_subnet_name=$(PACKER_SUBNET_NAME)

init:
packer init -upgrade .

build:
terraform init -input=false -reconfigure -backend-config="bucket=${TERRAFORM_STATE_BUCKET}"
$(tf_vars) terraform apply -auto-approve -input=false -compact-warnings
packer build -var "gcp_project_id=$(GCP_PROJECT_ID)" -var "gcp_zone=$(GCP_ZONE)" -var "network_name=$(NETWORK_NAME)" .
$(tf_vars) terraform apply -auto-approve -input=false -upgrade -compact-warnings
Comment thread
sitole marked this conversation as resolved.
Comment thread
sitole marked this conversation as resolved.
packer build -var "gcp_project_id=$(GCP_PROJECT_ID)" -var "gcp_zone=$(GCP_ZONE)" -var "network_name=$(PACKER_NETWORK_NAME)" -var "subnet_name=$(PACKER_NETWORK_NAME)" .
Comment thread
sitole marked this conversation as resolved.
Comment thread
sitole marked this conversation as resolved.
Comment thread
sitole marked this conversation as resolved.
Comment thread
sitole marked this conversation as resolved.

format:
packer fmt .
2 changes: 1 addition & 1 deletion iac/provider-gcp/nomad-cluster-disk-image/main.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ source "googlecompute" "orch" {

# Enable IAP for SSH
network = var.network_name
subnetwork = "${var.network_name}-subnetwork"
subnetwork = var.subnet_name
Comment thread
sitole marked this conversation as resolved.
use_iap = true
}

Expand Down
6 changes: 4 additions & 2 deletions iac/provider-gcp/nomad-cluster-disk-image/main.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
terraform {
required_version = ">= 1.5.0, < 1.6.0"

backend "gcs" {
prefix = "terraform/cluster-disk-image/state"
}

required_providers {
google = {
source = "hashicorp/google"
Expand All @@ -23,7 +25,7 @@ resource "google_compute_network" "packer_network" {

resource "google_compute_subnetwork" "packer_subnetwork" {
ip_cidr_range = "10.0.0.0/8"
name = "${var.network_name}-subnetwork"
name = var.subnet_name
network = google_compute_network.packer_network.id

log_config {
Expand All @@ -48,4 +50,4 @@ resource "google_compute_firewall" "internal_remote_connection_firewall_ingress"
direction = "INGRESS"
# https://googlecloudplatform.github.io/iap-desktop/setup-iap/
source_ranges = ["35.235.240.0/20"]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ variable "network_name" {
type = string
}

variable "subnet_name" {
type = string
}

variable "prefix" {
type = string
default = "e2b-"
Expand Down Expand Up @@ -39,4 +43,4 @@ variable "clickhouse_client_version" {
variable "cni_plugin_version" {
type = string
default = "v1.6.2"
}
}
4 changes: 4 additions & 0 deletions iac/provider-gcp/nomad-cluster-disk-image/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ variable "gcp_region" {
variable "network_name" {
type = string
}

variable "subnet_name" {
Comment thread
sitole marked this conversation as resolved.
type = string
}
Loading