75 lines
1.7 KiB
HCL
75 lines
1.7 KiB
HCL
terraform {
|
|
required_providers {
|
|
# official vercel/vercel provider seems less stable
|
|
vercel = {
|
|
source = "registry.terraform.io/chronark/vercel"
|
|
version = ">=0.10.3"
|
|
}
|
|
digitalocean = {
|
|
source = "digitalocean/digitalocean"
|
|
version = "~> 2.0"
|
|
}
|
|
local = {
|
|
source = "hashicorp/local"
|
|
version = "~> 2"
|
|
}
|
|
}
|
|
}
|
|
|
|
provider "vercel" {
|
|
token = var.vercel_api_token
|
|
}
|
|
|
|
provider "digitalocean" {
|
|
token = var.digital_ocean_token
|
|
}
|
|
|
|
resource "digitalocean_database_cluster" "metaforecast_db" {
|
|
name = "postgres-green"
|
|
engine = "pg"
|
|
size = "db-s-1vcpu-1gb"
|
|
region = "nyc1"
|
|
node_count = 1
|
|
version = 14
|
|
}
|
|
|
|
resource "vercel_project" "metaforecast" {
|
|
name = "metaforecast"
|
|
team_id = var.vercel_team
|
|
|
|
git_repository {
|
|
type = "github"
|
|
repo = "QURIresearch/metaforecast"
|
|
}
|
|
|
|
domain {
|
|
name = "metaforecast.org"
|
|
}
|
|
}
|
|
|
|
resource "vercel_env" "metaforecast" {
|
|
project_id = vercel_project.metaforecast.id
|
|
team_id = var.vercel_team
|
|
type = "plain"
|
|
for_each = var.metaforecast_env
|
|
key = each.key
|
|
value = each.value
|
|
target = ["preview", "production"]
|
|
}
|
|
|
|
resource "vercel_env" "metaforecast_db" {
|
|
project_id = vercel_project.metaforecast.id
|
|
team_id = var.vercel_team
|
|
type = "plain"
|
|
key = "DIGITALOCEAN_POSTGRES"
|
|
value = digitalocean_database_cluster.metaforecast_db.uri
|
|
target = ["preview", "production"]
|
|
}
|
|
|
|
# should probably be replaced with local bash script
|
|
# resource "local_file" "foo" {
|
|
# content = join("", concat(["# generated by terraform\n"], [for k, v in var.metaforecast_env : "${k} = \"${v}\"\n"]))
|
|
# filename = "${path.module}/../.env.prod"
|
|
# file_permission = "0644"
|
|
# }
|