Refactor terraform config and remove deletion protection var

This commit is contained in:
mitchell 2020-04-13 05:13:27 -04:00
parent 80d6cfbb31
commit e212eee751
1 changed files with 16 additions and 11 deletions

View File

@ -3,8 +3,8 @@
provider "google" { provider "google" {
version = "3.8.0" version = "3.8.0"
project = var.project_id project = var.project_id
region = "us-east4" region = var.region
zone = "us-east4-b" zone = var.zone
} }
variable "ssh_keys" { variable "ssh_keys" {
@ -17,10 +17,14 @@ variable "project_id" {
description = "The name of the google cloud project you're deploying to." description = "The name of the google cloud project you're deploying to."
} }
variable "deletion_protection" { variable "region" {
type = bool type = string
description = "Whether to apply deletion protection to the shortnr-instance." description = "The region you want your infrastructure to deploy to."
default = true }
variable "zone" {
type = string
description = "The zone, within the region, that you want to deploy to."
} }
output "shortnr_static_ip" { output "shortnr_static_ip" {
@ -35,12 +39,12 @@ data "google_compute_image" "debian_image" {
resource "google_compute_address" "shortnr" { resource "google_compute_address" "shortnr" {
name = "shortnr-address" name = "shortnr-address"
network_tier = "STANDARD"
} }
resource "google_compute_instance" "shortnr" { resource "google_compute_instance" "shortnr" {
name = "shortnr-instance" name = "shortnr-instance"
machine_type = "f1-micro" machine_type = "f1-micro"
deletion_protection = var.deletion_protection
boot_disk { boot_disk {
auto_delete = true auto_delete = true
@ -54,6 +58,7 @@ resource "google_compute_instance" "shortnr" {
network = "default" network = "default"
access_config { access_config {
nat_ip = google_compute_address.shortnr.address nat_ip = google_compute_address.shortnr.address
network_tier = "STANDARD"
} }
} }