Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
93c03e7e86
|
|||
|
2338c3c0ea
|
|||
|
a6d1a1e4a7
|
|||
|
07c52e22a1
|
|||
|
59690665db
|
|||
|
88efbe672d
|
|||
|
9be2e48a69
|
|||
|
e9f738a46f
|
|||
|
0ad4eeacc4
|
|||
|
4d31df68a9
|
|||
|
fa1e064ff8
|
|||
|
5acdb31ab5
|
|||
|
70835b86af
|
|||
|
46c95c1c6d
|
|||
|
1df1f4595a
|
|||
|
2c061156e7
|
|||
|
8e3411f7f1
|
|||
|
9226c1ad7a
|
|||
|
0e1347935b
|
|||
|
76233b84ea
|
|||
|
8d66adf74a
|
|||
|
efbba9cd51
|
|||
|
b1f8b7dfbc
|
|||
|
8bf63838c8
|
|||
|
f0cb096503
|
|||
|
345ea61288
|
|||
|
ad2657ce14
|
|||
|
037c3fb707
|
|||
| 42ad8e5fe8 | |||
| 072ee45d97 | |||
| 6c1860a9c8 | |||
| 4feec6f283 | |||
| a0a34fa304 | |||
| 6e5c110821 | |||
| 0e8563fc55 | |||
| 1052daee73 | |||
| b5bd33e13a | |||
| 2d2ce34446 | |||
| b2271ef6fc | |||
| f2f3381053 | |||
| 7f49a5ad6e | |||
| 6b6a944077 | |||
| cda8c77152 | |||
| 9afbd5a1c6 |
@@ -3,19 +3,19 @@ all: init fmt validate
|
||||
|
||||
.PHONY: init
|
||||
init:
|
||||
terraform init -upgrade=false
|
||||
tofu init -upgrade=false
|
||||
|
||||
.PHONY: initupgrade
|
||||
initupgrade:
|
||||
terraform init -upgrade=true
|
||||
tofu init -upgrade=true
|
||||
|
||||
.PHONY: fmt
|
||||
fmt: init
|
||||
terraform fmt
|
||||
tofu fmt
|
||||
|
||||
.PHONY: validate
|
||||
validate: init fmt
|
||||
terraform validate
|
||||
tofu validate
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
data "digitalocean_domain" "this" {
|
||||
name = var.domain_name
|
||||
}
|
||||
|
||||
|
||||
@@ -2,3 +2,4 @@ data "digitalocean_project" "this" {
|
||||
count = var.use_project > 0 ? 1 : 0
|
||||
name = var.project
|
||||
}
|
||||
|
||||
|
||||
@@ -2,3 +2,4 @@ data "digitalocean_vpc" "this" {
|
||||
count = var.use_vpc > 0 ? 1 : 0
|
||||
name = var.vpc_name
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
output "droplet" {
|
||||
value = digitalocean_droplet.this
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
resource "digitalocean_droplet" "this" {
|
||||
backups = "true"
|
||||
backup_policy {
|
||||
plan = var.backup_policy_plan
|
||||
weekday = var.backup_policy_weekday
|
||||
hour = var.backup_policy_hour
|
||||
}
|
||||
image = var.image_name
|
||||
ipv6 = "true"
|
||||
lifecycle {
|
||||
ignore_changes = [
|
||||
image,
|
||||
]
|
||||
}
|
||||
monitoring = "true"
|
||||
name = "${var.host_name}.${var.domain_name}"
|
||||
region = var.region
|
||||
@@ -10,3 +20,4 @@ resource "digitalocean_droplet" "this" {
|
||||
tags = var.tags
|
||||
vpc_uuid = var.use_vpc > 0 ? data.digitalocean_vpc.this[0].id : null
|
||||
}
|
||||
|
||||
|
||||
@@ -5,3 +5,4 @@ resource "digitalocean_project_resources" "this" {
|
||||
digitalocean_droplet.this.urn
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
resource "digitalocean_record" "A" {
|
||||
domain = data.digitalocean_domain.this.name
|
||||
name = var.host_name
|
||||
ttl = "300"
|
||||
type = "A"
|
||||
value = digitalocean_droplet.this.ipv4_address
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
resource "digitalocean_record" "AAAA" {
|
||||
domain = data.digitalocean_domain.this.name
|
||||
name = var.host_name
|
||||
ttl = "300"
|
||||
type = "AAAA"
|
||||
value = digitalocean_droplet.this.ipv6_address
|
||||
}
|
||||
|
||||
|
||||
@@ -5,3 +5,4 @@ resource "digitalocean_volume" "this" {
|
||||
region = var.region
|
||||
size = var.volume_size
|
||||
}
|
||||
|
||||
|
||||
@@ -3,3 +3,4 @@ resource "digitalocean_volume_attachment" "this" {
|
||||
droplet_id = digitalocean_droplet.this.id
|
||||
volume_id = digitalocean_volume.this[0].id
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -2,8 +2,9 @@ terraform {
|
||||
required_providers {
|
||||
digitalocean = {
|
||||
source = "digitalocean/digitalocean"
|
||||
version = ">= 2.21.0"
|
||||
version = ">= 2.87.0"
|
||||
}
|
||||
}
|
||||
required_version = ">= 1.2.4"
|
||||
required_version = ">= 1.11.5"
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
variable "backup_policy_hour" {
|
||||
# UTC Hour : 0, 4, 8, 12, 16, 20
|
||||
default = "0"
|
||||
type = string
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
variable "backup_policy_plan" {
|
||||
# daily or weekly
|
||||
default = "weekly"
|
||||
type = string
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
variable "backup_policy_weekday" {
|
||||
# SUN, MON, TUE, WED, THU, FRI, SAT
|
||||
default = "SUN"
|
||||
type = string
|
||||
}
|
||||
|
||||
@@ -2,3 +2,4 @@ variable "domain_name" {
|
||||
default = "example.com"
|
||||
type = string
|
||||
}
|
||||
|
||||
|
||||
@@ -2,3 +2,4 @@ variable "host_name" {
|
||||
default = "hello-world"
|
||||
type = string
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
variable "image_name" {
|
||||
default = "fedora-36-x64"
|
||||
default = "fedora-42-x64"
|
||||
type = string
|
||||
}
|
||||
|
||||
|
||||
@@ -2,3 +2,4 @@ variable "project" {
|
||||
default = "default"
|
||||
type = string
|
||||
}
|
||||
|
||||
|
||||
@@ -2,3 +2,4 @@ variable "region" {
|
||||
default = "nyc3"
|
||||
type = string
|
||||
}
|
||||
|
||||
|
||||
@@ -2,3 +2,4 @@ variable "size" {
|
||||
default = "s-1vcpu-1gb"
|
||||
type = string
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
variable "ssh_keys" {
|
||||
type = list(any)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,3 +2,4 @@ variable "tags" {
|
||||
default = []
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,3 +2,4 @@ variable "use_project" {
|
||||
default = 0
|
||||
type = number
|
||||
}
|
||||
|
||||
|
||||
@@ -2,3 +2,4 @@ variable "use_volume" {
|
||||
default = 0
|
||||
type = number
|
||||
}
|
||||
|
||||
|
||||
@@ -2,3 +2,4 @@ variable "use_vpc" {
|
||||
default = 0
|
||||
type = number
|
||||
}
|
||||
|
||||
|
||||
@@ -2,3 +2,4 @@ variable "volume_size" {
|
||||
default = 0
|
||||
type = number
|
||||
}
|
||||
|
||||
|
||||
@@ -2,3 +2,4 @@ variable "vpc_name" {
|
||||
default = "nyc3"
|
||||
type = string
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user