diff --git a/prod/backup/terraform/.terraform.lock.hcl b/prod/backup/terraform/.terraform.lock.hcl new file mode 100644 index 0000000..2a8e640 --- /dev/null +++ b/prod/backup/terraform/.terraform.lock.hcl @@ -0,0 +1,25 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/digitalocean/digitalocean" { + version = "2.19.0" + constraints = "~> 2.19.0" + hashes = [ + "h1:z3FmDpOuKq+bOYgFE5MtFpXjOL2gAbtutL4jeAd9rJE=", + "zh:01cee85343dee2dfc01499e19ef4e56b0c9260eee0a47329231cf500c07b4386", + "zh:099eeddf9baf9c282430231da501a8b96b3fb28507ce3b78e3a185cc9d4b3860", + "zh:191e090e8553355d91842163737d71051aeb499c8ddb23d2e8aae9dab2f8a1a5", + "zh:25356abb47769270730b0ddb0a3eb89aec637395cdcb77c309d23e55839e4461", + "zh:28876afb75ba5367d20e508e05c7657f90922142ff80d8a81a4d68b3381adb86", + "zh:404a304e37c3dec8017318b16ab701553e5242dc2460211346a9dd39242709a6", + "zh:40f53111b01fc78fdc7a6ba47a80d51c9a45e77e5b7d7d5bcae3a0c6f58ffbdf", + "zh:48f212068234df3dcfe5544c96b10403b15a190203742756d7d0573ee0857c17", + "zh:5189fe4fffdbff5c280f6741f55b2de9cb2b8c653cda0b2339c28cd1e3bc7884", + "zh:a7d5840ca789a03a285c67d2838af4d8687c99f3e8fac4ce56fcd23802a66156", + "zh:c0bd3c4555e5d7e6c96d3add3ddd8e41aa0df9e4a4518ad3b7f1d726a4e0a9f4", + "zh:d70a903a6d75533aa4713e255c9c967ec453195f2209439981f015f203805a6e", + "zh:db8110736bd47f99213d72309ebb720718a80b15ddd46e34a8ee9b2125903079", + "zh:e2180f334506601e0a6af8863159cc719ce584fdb23bd45ddc120f33d22cec19", + "zh:eb515a24d231e7f1ef344b9b88fa2071f760ec34fbb47d80bbacdf7e35f3daca", + ] +} diff --git a/prod/backup/terraform/main.tf b/prod/backup/terraform/main.tf new file mode 100644 index 0000000..6a69520 --- /dev/null +++ b/prod/backup/terraform/main.tf @@ -0,0 +1,14 @@ +provider "digitalocean" { + token = var.do_token + spaces_access_id = var.spaces_access_id + spaces_secret_key = var.spaces_secret_key +} + +resource "digitalocean_spaces_bucket" "jdormit_backup" { + name = "jdormit-backup" + region = "nyc3" + + lifecycle { + prevent_destroy = true + } +} diff --git a/prod/backup/terraform/outputs.tf b/prod/backup/terraform/outputs.tf new file mode 100644 index 0000000..95ccd91 --- /dev/null +++ b/prod/backup/terraform/outputs.tf @@ -0,0 +1,3 @@ +output "jdormit_backup_bucket_urn" { + value = digitalocean_spaces_bucket.jdormit_backup.urn +} diff --git a/prod/backup/terraform/terraform.tf b/prod/backup/terraform/terraform.tf new file mode 100644 index 0000000..62a481a --- /dev/null +++ b/prod/backup/terraform/terraform.tf @@ -0,0 +1,18 @@ +terraform { + required_providers { + digitalocean = { + source = "digitalocean/digitalocean" + version = "~> 2.19.0" + } + } + + backend "s3" { + skip_credentials_validation = true + skip_metadata_api_check = true + # Need to specify an AWS region to stop Terraform complaining + region = "us-east-1" + endpoint = "nyc3.digitaloceanspaces.com" + bucket = "jdormit-tf-state" + key = "prod/backup.tfstate" + } +} diff --git a/prod/backup/terraform/variables.tf b/prod/backup/terraform/variables.tf new file mode 100644 index 0000000..1b3748a --- /dev/null +++ b/prod/backup/terraform/variables.tf @@ -0,0 +1,11 @@ +variable "do_token" { + type = string +} + +variable "spaces_access_id" { + type = string +} + +variable "spaces_secret_key" { + type = string +}