Skip to content

Commit

Permalink
add networks.tf
Browse files Browse the repository at this point in the history
  • Loading branch information
08sm80 committed Sep 24, 2024
1 parent 00d91c3 commit 1dab60a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
27 changes: 12 additions & 15 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@

# Networks config

data "google_compute_network" "default" { # existing default network
name = "default"
}

data "google_compute_network" "vpc1" { # existing custom network
name = "vpc1"
}

data "google_compute_subnetwork" "vpc1_sn2" {
name = "vpc1-sn2"
}
# moved to networks.tf

# Compute

Expand Down Expand Up @@ -45,10 +34,18 @@ resource "google_compute_instance" "gce_vm1" {
}

metadata = {
ninja = "level-1"
ninja = "level-1"
enable-oslogin = false
startup-script = <<-EOT
#! /bin/bash
sudo apt update
sudo apt install busybox -y
echo "Hello, World" > index.xhtml
nohup busybox httpd -f -p 8080 &
EOT
}

metadata_startup_script = "echo hi > /test.txt"


service_account {
# Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles.
Expand All @@ -63,7 +60,7 @@ resource "google_compute_firewall" "basic_access" {
name = "basic-access"
allow {
protocol = "TCP"
ports = ["80", "443", "22"]
ports = ["80", "443", "22", "8080"]
}
source_ranges = ["0.0.0.0/0"]
}
11 changes: 11 additions & 0 deletions networks.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
data "google_compute_network" "default" { # existing default network
name = "default"
}

data "google_compute_network" "vpc1" { # existing custom network
name = "vpc1"
}

data "google_compute_subnetwork" "vpc1_sn2" {
name = "vpc1-sn2"
}
5 changes: 5 additions & 0 deletions templates/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
set -e -x -u -o pipefail

echo "Hello, World" > index.xhtml
nohup busybox httpd -f -p 8080 &

0 comments on commit 1dab60a

Please sign in to comment.