Make Private Networking optional

This commit is contained in:
Jason Rothstein 2021-05-01 17:54:31 -05:00
parent 64d119f011
commit 334f8165d3
4 changed files with 9 additions and 4 deletions

View File

@ -1,3 +1,4 @@
data "digitalocean_vpc" "this" {
name = var.vpc_name
count = var.use_vpc > 0 ? 1 : 0
name = var.vpc_name
}

View File

@ -4,10 +4,10 @@ resource "digitalocean_droplet" "this" {
ipv6 = "true"
monitoring = "true"
name = "${var.host_name}.${var.domain_name}"
private_networking = "true"
private_networking = var.use_vpc > 0 ? "true" : "false"
region = var.region
ssh_keys = var.ssh_keys
size = var.size
tags = var.tags
vpc_uuid = data.digitalocean_vpc.this.id
vpc_uuid = var.use_vpc > 0 ? data.digitalocean_vpc.this[0].id : ""
}

View File

@ -2,7 +2,7 @@ terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
version = ">= 2.7.0"
version = ">= 2.8.0"
}
}
required_version = ">= 0.14"

4
variable.use_vpc.tf Normal file
View File

@ -0,0 +1,4 @@
variable "use_vpc" {
default = 0
type = number
}