From 751cce19c56e05fbff0bcca2db6a3d679cffa451 Mon Sep 17 00:00:00 2001 From: shane Date: Sun, 29 Jan 2023 12:31:47 -0600 Subject: [PATCH] Add first-working deployment of bucket and CDN --- provider.tf | 12 +++++++++++- website.tf | 13 ++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/provider.tf b/provider.tf index bc95bdb..3be3f96 100644 --- a/provider.tf +++ b/provider.tf @@ -11,6 +11,16 @@ terraform { } } +provider "digitalocean" { + token = var.do_token + spaces_access_id = var.spaces_access_id + spaces_secret_key = var.spaces_secret +} + provider "acme" { server_url = "https://acme-v02.api.letsencrypt.org/directory" -} \ No newline at end of file +} + +variable "do_token" {} +variable "spaces_access_id" {} +variable "spaces_secret" {} \ No newline at end of file diff --git a/website.tf b/website.tf index f9b37dd..610782d 100644 --- a/website.tf +++ b/website.tf @@ -21,7 +21,7 @@ resource "local_file" "static_dir" { } # Create local files as scratch space -resource "local_file" "example" { +resource "local_file" "policy" { filename = ".well-known/openpgpkey/policy" content = "" depends_on = [local_file.openpgpkey] @@ -40,12 +40,19 @@ resource "local_file" "example" { # depends_on = [local_exec.command1] # } -# Create the Space on Digital Ocean +# Create a new Spaces Bucket resource "digitalocean_spaces_bucket" "distrust_co" { - name = "distrust.co" + name = "distrust-co" region = "nyc3" + acl = "public-read" } +# Add a CDN endpoint to the Spaces Bucket resource "digitalocean_cdn" "distrust_co" { origin = digitalocean_spaces_bucket.distrust_co.bucket_domain_name +} + +# Output the endpoint for the CDN resource +output "fqdn" { + value = digitalocean_cdn.distrust_co.endpoint } \ No newline at end of file