Make Private Networking optional
This commit is contained in:
parent
64d119f011
commit
334f8165d3
@ -1,3 +1,4 @@
|
||||
data "digitalocean_vpc" "this" {
|
||||
name = var.vpc_name
|
||||
count = var.use_vpc > 0 ? 1 : 0
|
||||
name = var.vpc_name
|
||||
}
|
||||
|
@ -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 : ""
|
||||
}
|
||||
|
@ -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
4
variable.use_vpc.tf
Normal file
@ -0,0 +1,4 @@
|
||||
variable "use_vpc" {
|
||||
default = 0
|
||||
type = number
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user