Enable project and volume usage to be optional, off by default, unless the use_project and use_volume variables are set to a positive number
This commit is contained in:
parent
3f903bcb6c
commit
9fb985dae4
@ -1,3 +1,4 @@
|
||||
data "digitalocean_project" "this" {
|
||||
name = var.project
|
||||
count = var.use_project > 0 ? 1 : 0
|
||||
name = var.project
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
resource "digitalocean_project_resources" "this" {
|
||||
project = data.digitalocean_project.this.id
|
||||
count = var.use_project > 0 ? 1 : 0
|
||||
project = data.digitalocean_project.this[0].id
|
||||
resources = [
|
||||
digitalocean_droplet.this.urn
|
||||
]
|
||||
|
@ -1,8 +1,7 @@
|
||||
resource "digitalocean_volume" "this" {
|
||||
count = var.volume_size > 1 ? 1 : 0
|
||||
description = "Data Volume for ${var.host_name}.${var.domain_name}"
|
||||
initial_filesystem_type = "ext4"
|
||||
name = var.host_name
|
||||
region = var.region
|
||||
size = var.volume_size
|
||||
count = var.use_volume > 0 ? 1 : 0
|
||||
description = "Data Volume for ${var.host_name}.${var.domain_name}"
|
||||
name = var.host_name
|
||||
region = var.region
|
||||
size = var.volume_size
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
resource "digitalocean_volume_attachment" "this" {
|
||||
count = var.volume_size > 0 ? 1 : 0
|
||||
count = var.use_volume > 0 ? 1 : 0
|
||||
droplet_id = digitalocean_droplet.this.id
|
||||
volume_id = digitalocean_volume.this[0].id
|
||||
}
|
||||
|
4
variable.use_project.tf
Normal file
4
variable.use_project.tf
Normal file
@ -0,0 +1,4 @@
|
||||
variable "use_project" {
|
||||
default = 0
|
||||
type = number
|
||||
}
|
4
variable.use_volume.tf
Normal file
4
variable.use_volume.tf
Normal file
@ -0,0 +1,4 @@
|
||||
variable "use_volume" {
|
||||
default = 0
|
||||
type = number
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
variable "volume_size" {
|
||||
default = "0"
|
||||
default = 0
|
||||
type = number
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user