From e212eee7510b6983b70610dd638d7d5474581f55 Mon Sep 17 00:00:00 2001 From: mitchell Date: Mon, 13 Apr 2020 05:13:27 -0400 Subject: [PATCH] Refactor terraform config and remove deletion protection var --- infra/main.tf | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/infra/main.tf b/infra/main.tf index 70a4b9c..6ad2413 100644 --- a/infra/main.tf +++ b/infra/main.tf @@ -3,8 +3,8 @@ provider "google" { version = "3.8.0" project = var.project_id - region = "us-east4" - zone = "us-east4-b" + region = var.region + zone = var.zone } variable "ssh_keys" { @@ -17,10 +17,14 @@ variable "project_id" { description = "The name of the google cloud project you're deploying to." } -variable "deletion_protection" { - type = bool - description = "Whether to apply deletion protection to the shortnr-instance." - default = true +variable "region" { + type = string + description = "The region you want your infrastructure to deploy to." +} + +variable "zone" { + type = string + description = "The zone, within the region, that you want to deploy to." } output "shortnr_static_ip" { @@ -34,13 +38,13 @@ data "google_compute_image" "debian_image" { } resource "google_compute_address" "shortnr" { - name = "shortnr-address" + name = "shortnr-address" + network_tier = "STANDARD" } resource "google_compute_instance" "shortnr" { - name = "shortnr-instance" - machine_type = "f1-micro" - deletion_protection = var.deletion_protection + name = "shortnr-instance" + machine_type = "f1-micro" boot_disk { auto_delete = true @@ -53,7 +57,8 @@ resource "google_compute_instance" "shortnr" { network_interface { network = "default" access_config { - nat_ip = google_compute_address.shortnr.address + nat_ip = google_compute_address.shortnr.address + network_tier = "STANDARD" } }