mirror of https://github.com/mitchell/shortnr.git
Refactor terraform config and remove deletion protection var
This commit is contained in:
parent
80d6cfbb31
commit
e212eee751
|
@ -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" {
|
||||||
|
@ -34,13 +38,13 @@ 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
|
||||||
|
@ -53,7 +57,8 @@ resource "google_compute_instance" "shortnr" {
|
||||||
network_interface {
|
network_interface {
|
||||||
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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue