Convert terraform to modern style

This commit is contained in:
Daniel Goldberg 2019-11-27 13:41:02 +02:00
parent e92665a427
commit 052e853b20
5 changed files with 82 additions and 82 deletions

View File

@ -2,7 +2,7 @@ provider "google" {
project = "test-000000"
region = "europe-west3"
zone = "europe-west3-b"
credentials = "${file("../gcp_keys/gcp_key.json")}"
credentials = file("../gcp_keys/gcp_key.json")
}
locals {
resource_prefix = ""

View File

@ -1,6 +1,6 @@
resource "google_compute_firewall" "islands-in" {
name = "${local.resource_prefix}islands-in"
network = "${google_compute_network.monkeyzoo.name}"
network = google_compute_network.monkeyzoo.name
allow {
protocol = "tcp"
@ -14,7 +14,7 @@ resource "google_compute_firewall" "islands-in" {
resource "google_compute_firewall" "islands-out" {
name = "${local.resource_prefix}islands-out"
network = "${google_compute_network.monkeyzoo.name}"
network = google_compute_network.monkeyzoo.name
allow {
protocol = "tcp"
@ -27,7 +27,7 @@ resource "google_compute_firewall" "islands-out" {
resource "google_compute_firewall" "monkeyzoo-in" {
name = "${local.resource_prefix}monkeyzoo-in"
network = "${google_compute_network.monkeyzoo.name}"
network = google_compute_network.monkeyzoo.name
allow {
protocol = "all"
@ -40,7 +40,7 @@ resource "google_compute_firewall" "monkeyzoo-in" {
resource "google_compute_firewall" "monkeyzoo-out" {
name = "${local.resource_prefix}monkeyzoo-out"
network = "${google_compute_network.monkeyzoo.name}"
network = google_compute_network.monkeyzoo.name
allow {
protocol = "all"
@ -53,7 +53,7 @@ resource "google_compute_firewall" "monkeyzoo-out" {
resource "google_compute_firewall" "tunneling-in" {
name = "${local.resource_prefix}tunneling-in"
network = "${google_compute_network.tunneling.name}"
network = google_compute_network.tunneling.name
allow {
protocol = "all"
@ -65,7 +65,7 @@ resource "google_compute_firewall" "tunneling-in" {
resource "google_compute_firewall" "tunneling-out" {
name = "${local.resource_prefix}tunneling-out"
network = "${google_compute_network.tunneling.name}"
network = google_compute_network.tunneling.name
allow {
protocol = "all"
@ -77,7 +77,7 @@ resource "google_compute_firewall" "tunneling-out" {
resource "google_compute_firewall" "tunneling2-in" {
name = "${local.resource_prefix}tunneling2-in"
network = "${google_compute_network.tunneling2.name}"
network = google_compute_network.tunneling2.name
allow {
protocol = "all"
@ -89,7 +89,7 @@ resource "google_compute_firewall" "tunneling2-in" {
resource "google_compute_firewall" "tunneling2-out" {
name = "${local.resource_prefix}tunneling2-out"
network = "${google_compute_network.tunneling2.name}"
network = google_compute_network.tunneling2.name
allow {
protocol = "all"

View File

@ -1,19 +1,19 @@
//Custom cloud images
data "google_compute_image" "hadoop-2" {
name = "hadoop-2"
project = "${local.monkeyzoo_project}"
project = local.monkeyzoo_project
}
data "google_compute_image" "hadoop-3" {
name = "hadoop-3"
project = "${local.monkeyzoo_project}"
project = local.monkeyzoo_project
}
data "google_compute_image" "elastic-4" {
name = "elastic-4"
project = "${local.monkeyzoo_project}"
project = local.monkeyzoo_project
}
data "google_compute_image" "elastic-5" {
name = "elastic-5"
project = "${local.monkeyzoo_project}"
project = local.monkeyzoo_project
}
/*
@ -23,73 +23,73 @@ data "google_compute_image" "sambacry-6" {
*/
data "google_compute_image" "shellshock-8" {
name = "shellshock-8"
project = "${local.monkeyzoo_project}"
project = local.monkeyzoo_project
}
data "google_compute_image" "tunneling-9" {
name = "tunneling-9"
project = "${local.monkeyzoo_project}"
project = local.monkeyzoo_project
}
data "google_compute_image" "tunneling-10" {
name = "tunneling-10"
project = "${local.monkeyzoo_project}"
project = local.monkeyzoo_project
}
data "google_compute_image" "tunneling-11" {
name = "tunneling-11"
project = "${local.monkeyzoo_project}"
project = local.monkeyzoo_project
}
data "google_compute_image" "sshkeys-11" {
name = "sshkeys-11"
project = "${local.monkeyzoo_project}"
project = local.monkeyzoo_project
}
data "google_compute_image" "sshkeys-12" {
name = "sshkeys-12"
project = "${local.monkeyzoo_project}"
project = local.monkeyzoo_project
}
data "google_compute_image" "mimikatz-14" {
name = "mimikatz-14"
project = "${local.monkeyzoo_project}"
project = local.monkeyzoo_project
}
data "google_compute_image" "mimikatz-15" {
name = "mimikatz-15"
project = "${local.monkeyzoo_project}"
project = local.monkeyzoo_project
}
data "google_compute_image" "mssql-16" {
name = "mssql-16"
project = "${local.monkeyzoo_project}"
project = local.monkeyzoo_project
}
data "google_compute_image" "weblogic-18" {
name = "weblogic-18"
project = "${local.monkeyzoo_project}"
project = local.monkeyzoo_project
}
data "google_compute_image" "weblogic-19" {
name = "weblogic-19"
project = "${local.monkeyzoo_project}"
project = local.monkeyzoo_project
}
data "google_compute_image" "smb-20" {
name = "smb-20"
project = "${local.monkeyzoo_project}"
project = local.monkeyzoo_project
}
data "google_compute_image" "scan-21" {
name = "scan-21"
project = "${local.monkeyzoo_project}"
project = local.monkeyzoo_project
}
data "google_compute_image" "scan-22" {
name = "scan-22"
project = "${local.monkeyzoo_project}"
project = local.monkeyzoo_project
}
data "google_compute_image" "struts2-23" {
name = "struts2-23"
project = "${local.monkeyzoo_project}"
project = local.monkeyzoo_project
}
data "google_compute_image" "struts2-24" {
name = "struts2-24"
project = "${local.monkeyzoo_project}"
project = local.monkeyzoo_project
}
data "google_compute_image" "island-linux-250" {
name = "island-linux-250"
project = "${local.monkeyzoo_project}"
project = local.monkeyzoo_project
}
data "google_compute_image" "island-windows-251" {
name = "island-windows-251"
project = "${local.monkeyzoo_project}"
project = local.monkeyzoo_project
}

View File

@ -1,8 +1,8 @@
// Local variables
locals {
default_ubuntu="${google_compute_instance_template.ubuntu16.self_link}"
default_windows="${google_compute_instance_template.windows2016.self_link}"
default_ubuntu=google_compute_instance_template.ubuntu16.self_link
default_windows=google_compute_instance_template.windows2016.self_link
}
resource "google_compute_network" "monkeyzoo" {
@ -23,27 +23,27 @@ resource "google_compute_network" "tunneling2" {
resource "google_compute_subnetwork" "monkeyzoo-main" {
name = "${local.resource_prefix}monkeyzoo-main"
ip_cidr_range = "10.2.2.0/24"
network = "${google_compute_network.monkeyzoo.self_link}"
network = google_compute_network.monkeyzoo.self_link
}
resource "google_compute_subnetwork" "tunneling-main" {
name = "${local.resource_prefix}tunneling-main"
ip_cidr_range = "10.2.1.0/28"
network = "${google_compute_network.tunneling.self_link}"
network = google_compute_network.tunneling.self_link
}
resource "google_compute_subnetwork" "tunneling2-main" {
name = "${local.resource_prefix}tunneling2-main"
ip_cidr_range = "10.2.0.0/27"
network = "${google_compute_network.tunneling2.self_link}"
network = google_compute_network.tunneling2.self_link
}
resource "google_compute_instance_from_template" "hadoop-2" {
name = "${local.resource_prefix}hadoop-2"
source_instance_template = "${local.default_ubuntu}"
source_instance_template = local.default_ubuntu
boot_disk{
initialize_params {
image = "${data.google_compute_image.hadoop-2.self_link}"
image = data.google_compute_image.hadoop-2.self_link
}
auto_delete = true
}
@ -57,10 +57,10 @@ resource "google_compute_instance_from_template" "hadoop-2" {
resource "google_compute_instance_from_template" "hadoop-3" {
name = "${local.resource_prefix}hadoop-3"
source_instance_template = "${local.default_windows}"
source_instance_template = local.default_windows
boot_disk{
initialize_params {
image = "${data.google_compute_image.hadoop-3.self_link}"
image = data.google_compute_image.hadoop-3.self_link
}
auto_delete = true
}
@ -72,10 +72,10 @@ resource "google_compute_instance_from_template" "hadoop-3" {
resource "google_compute_instance_from_template" "elastic-4" {
name = "${local.resource_prefix}elastic-4"
source_instance_template = "${local.default_ubuntu}"
source_instance_template = local.default_ubuntu
boot_disk{
initialize_params {
image = "${data.google_compute_image.elastic-4.self_link}"
image = data.google_compute_image.elastic-4.self_link
}
auto_delete = true
}
@ -87,10 +87,10 @@ resource "google_compute_instance_from_template" "elastic-4" {
resource "google_compute_instance_from_template" "elastic-5" {
name = "${local.resource_prefix}elastic-5"
source_instance_template = "${local.default_windows}"
source_instance_template = local.default_windows
boot_disk{
initialize_params {
image = "${data.google_compute_image.elastic-5.self_link}"
image = data.google_compute_image.elastic-5.self_link
}
auto_delete = true
}
@ -135,10 +135,10 @@ resource "google_compute_instance_from_template" "sambacry-7" {
resource "google_compute_instance_from_template" "shellshock-8" {
name = "${local.resource_prefix}shellshock-8"
source_instance_template = "${local.default_ubuntu}"
source_instance_template = local.default_ubuntu
boot_disk{
initialize_params {
image = "${data.google_compute_image.shellshock-8.self_link}"
image = data.google_compute_image.shellshock-8.self_link
}
auto_delete = true
}
@ -150,10 +150,10 @@ resource "google_compute_instance_from_template" "shellshock-8" {
resource "google_compute_instance_from_template" "tunneling-9" {
name = "${local.resource_prefix}tunneling-9"
source_instance_template = "${local.default_ubuntu}"
source_instance_template = local.default_ubuntu
boot_disk{
initialize_params {
image = "${data.google_compute_image.tunneling-9.self_link}"
image = data.google_compute_image.tunneling-9.self_link
}
auto_delete = true
}
@ -169,10 +169,10 @@ resource "google_compute_instance_from_template" "tunneling-9" {
resource "google_compute_instance_from_template" "tunneling-10" {
name = "${local.resource_prefix}tunneling-10"
source_instance_template = "${local.default_ubuntu}"
source_instance_template = local.default_ubuntu
boot_disk{
initialize_params {
image = "${data.google_compute_image.tunneling-10.self_link}"
image = data.google_compute_image.tunneling-10.self_link
}
auto_delete = true
}
@ -188,10 +188,10 @@ resource "google_compute_instance_from_template" "tunneling-10" {
resource "google_compute_instance_from_template" "tunneling-11" {
name = "${local.resource_prefix}tunneling-11"
source_instance_template = "${local.default_ubuntu}"
source_instance_template = local.default_ubuntu
boot_disk{
initialize_params {
image = "${data.google_compute_image.tunneling-11.self_link}"
image = data.google_compute_image.tunneling-11.self_link
}
auto_delete = true
}
@ -203,10 +203,10 @@ resource "google_compute_instance_from_template" "tunneling-11" {
resource "google_compute_instance_from_template" "sshkeys-11" {
name = "${local.resource_prefix}sshkeys-11"
source_instance_template = "${local.default_ubuntu}"
source_instance_template = local.default_ubuntu
boot_disk{
initialize_params {
image = "${data.google_compute_image.sshkeys-11.self_link}"
image = data.google_compute_image.sshkeys-11.self_link
}
auto_delete = true
}
@ -218,10 +218,10 @@ resource "google_compute_instance_from_template" "sshkeys-11" {
resource "google_compute_instance_from_template" "sshkeys-12" {
name = "${local.resource_prefix}sshkeys-12"
source_instance_template = "${local.default_ubuntu}"
source_instance_template = local.default_ubuntu
boot_disk{
initialize_params {
image = "${data.google_compute_image.sshkeys-12.self_link}"
image = data.google_compute_image.sshkeys-12.self_link
}
auto_delete = true
}
@ -249,10 +249,10 @@ resource "google_compute_instance_from_template" "rdpgrinder-13" {
resource "google_compute_instance_from_template" "mimikatz-14" {
name = "${local.resource_prefix}mimikatz-14"
source_instance_template = "${local.default_windows}"
source_instance_template = local.default_windows
boot_disk{
initialize_params {
image = "${data.google_compute_image.mimikatz-14.self_link}"
image = data.google_compute_image.mimikatz-14.self_link
}
auto_delete = true
}
@ -264,10 +264,10 @@ resource "google_compute_instance_from_template" "mimikatz-14" {
resource "google_compute_instance_from_template" "mimikatz-15" {
name = "${local.resource_prefix}mimikatz-15"
source_instance_template = "${local.default_windows}"
source_instance_template = local.default_windows
boot_disk{
initialize_params {
image = "${data.google_compute_image.mimikatz-15.self_link}"
image = data.google_compute_image.mimikatz-15.self_link
}
auto_delete = true
}
@ -279,10 +279,10 @@ resource "google_compute_instance_from_template" "mimikatz-15" {
resource "google_compute_instance_from_template" "mssql-16" {
name = "${local.resource_prefix}mssql-16"
source_instance_template = "${local.default_windows}"
source_instance_template = local.default_windows
boot_disk{
initialize_params {
image = "${data.google_compute_image.mssql-16.self_link}"
image = data.google_compute_image.mssql-16.self_link
}
auto_delete = true
}
@ -314,10 +314,10 @@ resource "google_compute_instance_from_template" "upgrader-17" {
resource "google_compute_instance_from_template" "weblogic-18" {
name = "${local.resource_prefix}weblogic-18"
source_instance_template = "${local.default_ubuntu}"
source_instance_template = local.default_ubuntu
boot_disk{
initialize_params {
image = "${data.google_compute_image.weblogic-18.self_link}"
image = data.google_compute_image.weblogic-18.self_link
}
auto_delete = true
}
@ -329,10 +329,10 @@ resource "google_compute_instance_from_template" "weblogic-18" {
resource "google_compute_instance_from_template" "weblogic-19" {
name = "${local.resource_prefix}weblogic-19"
source_instance_template = "${local.default_windows}"
source_instance_template = local.default_windows
boot_disk{
initialize_params {
image = "${data.google_compute_image.weblogic-19.self_link}"
image = data.google_compute_image.weblogic-19.self_link
}
auto_delete = true
}
@ -344,10 +344,10 @@ resource "google_compute_instance_from_template" "weblogic-19" {
resource "google_compute_instance_from_template" "smb-20" {
name = "${local.resource_prefix}smb-20"
source_instance_template = "${local.default_windows}"
source_instance_template = local.default_windows
boot_disk{
initialize_params {
image = "${data.google_compute_image.smb-20.self_link}"
image = data.google_compute_image.smb-20.self_link
}
auto_delete = true
}
@ -359,10 +359,10 @@ resource "google_compute_instance_from_template" "smb-20" {
resource "google_compute_instance_from_template" "scan-21" {
name = "${local.resource_prefix}scan-21"
source_instance_template = "${local.default_ubuntu}"
source_instance_template = local.default_ubuntu
boot_disk{
initialize_params {
image = "${data.google_compute_image.scan-21.self_link}"
image = data.google_compute_image.scan-21.self_link
}
auto_delete = true
}
@ -374,10 +374,10 @@ resource "google_compute_instance_from_template" "scan-21" {
resource "google_compute_instance_from_template" "scan-22" {
name = "${local.resource_prefix}scan-22"
source_instance_template = "${local.default_windows}"
source_instance_template = local.default_windows
boot_disk{
initialize_params {
image = "${data.google_compute_image.scan-22.self_link}"
image = data.google_compute_image.scan-22.self_link
}
auto_delete = true
}
@ -389,10 +389,10 @@ resource "google_compute_instance_from_template" "scan-22" {
resource "google_compute_instance_from_template" "struts2-23" {
name = "${local.resource_prefix}struts2-23"
source_instance_template = "${local.default_ubuntu}"
source_instance_template = local.default_ubuntu
boot_disk{
initialize_params {
image = "${data.google_compute_image.struts2-23.self_link}"
image = data.google_compute_image.struts2-23.self_link
}
auto_delete = true
}
@ -404,10 +404,10 @@ resource "google_compute_instance_from_template" "struts2-23" {
resource "google_compute_instance_from_template" "struts2-24" {
name = "${local.resource_prefix}struts2-24"
source_instance_template = "${local.default_windows}"
source_instance_template = local.default_windows
boot_disk{
initialize_params {
image = "${data.google_compute_image.struts2-24.self_link}"
image = data.google_compute_image.struts2-24.self_link
}
auto_delete = true
}
@ -421,10 +421,10 @@ resource "google_compute_instance_from_template" "island-linux-250" {
name = "${local.resource_prefix}island-linux-250"
machine_type = "n1-standard-2"
tags = ["island", "linux", "ubuntu16"]
source_instance_template = "${local.default_ubuntu}"
source_instance_template = local.default_ubuntu
boot_disk{
initialize_params {
image = "${data.google_compute_image.island-linux-250.self_link}"
image = data.google_compute_image.island-linux-250.self_link
}
auto_delete = true
}
@ -442,10 +442,10 @@ resource "google_compute_instance_from_template" "island-windows-251" {
name = "${local.resource_prefix}island-windows-251"
machine_type = "n1-standard-2"
tags = ["island", "windows", "windowsserver2016"]
source_instance_template = "${local.default_windows}"
source_instance_template = local.default_windows
boot_disk{
initialize_params {
image = "${data.google_compute_image.island-windows-251.self_link}"
image = data.google_compute_image.island-windows-251.self_link
}
auto_delete = true
}

View File

@ -18,7 +18,7 @@ resource "google_compute_instance_template" "ubuntu16" {
}
}
service_account {
email ="${local.service_account_email}"
email =local.service_account_email
scopes=["cloud-platform"]
}
}
@ -39,7 +39,7 @@ resource "google_compute_instance_template" "windows2016" {
subnetwork="monkeyzoo-main"
}
service_account {
email="${local.service_account_email}"
email=local.service_account_email
scopes=["cloud-platform"]
}
}