-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject.tf
45 lines (39 loc) · 2.18 KB
/
project.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
///////////////////////////////////////////////////////////[ PROJECT ]////////////////////////////////////////////////////
# # ---------------------------------------------------------------------------------------------------------------------#
# Define brand or business name
# # ---------------------------------------------------------------------------------------------------------------------#
variable "brand" {
default = "magenx"
}
# # ---------------------------------------------------------------------------------------------------------------------#
# Create hash number to assign to project name
# # ---------------------------------------------------------------------------------------------------------------------#
resource "random_string" "project" {
length = 7
lower = true
number = true
special = false
upper = false
}
# # ---------------------------------------------------------------------------------------------------------------------#
# Create global project name to be assigned per environment
# # ---------------------------------------------------------------------------------------------------------------------#
locals {
project_prefix = lower("${var.brand}-${random_string.project.result}")
environment = lower(terraform.workspace)
}
# # ---------------------------------------------------------------------------------------------------------------------#
# Create project per environment
# # ---------------------------------------------------------------------------------------------------------------------#
resource "digitalocean_project" "this" {
name = "${local.project_prefix}-${local.environment}"
description = "Project for ${local.project_prefix} ${local.environment}"
purpose = "Infrastructure for ${local.project_prefix} ${local.environment}"
environment = title(local.environment)
}
# # ---------------------------------------------------------------------------------------------------------------------#
# Get project data
# # ---------------------------------------------------------------------------------------------------------------------#
locals {
project = digitalocean_project.this
}