ops: heroku
This commit is contained in:
parent
ee07435c62
commit
860fc1eb70
33
tf/main.tf
33
tf/main.tf
|
@ -9,6 +9,10 @@ terraform {
|
|||
source = "digitalocean/digitalocean"
|
||||
version = "~> 2.0"
|
||||
}
|
||||
heroku = {
|
||||
source = "heroku/heroku"
|
||||
version = "~> 5.0.2"
|
||||
}
|
||||
local = {
|
||||
source = "hashicorp/local"
|
||||
version = "~> 2"
|
||||
|
@ -24,6 +28,11 @@ provider "digitalocean" {
|
|||
token = var.digital_ocean_token
|
||||
}
|
||||
|
||||
provider "heroku" {
|
||||
email = "me@berekuk.ru"
|
||||
api_key = var.heroku_api_key
|
||||
}
|
||||
|
||||
resource "digitalocean_database_cluster" "metaforecast_db" {
|
||||
name = "postgres-green"
|
||||
engine = "pg"
|
||||
|
@ -33,6 +42,19 @@ resource "digitalocean_database_cluster" "metaforecast_db" {
|
|||
version = 14
|
||||
}
|
||||
|
||||
locals {
|
||||
generated_env = merge(var.metaforecast_env, {
|
||||
DIGITALOCEAN_POSTGRES = digitalocean_database_cluster.metaforecast_db.uri
|
||||
})
|
||||
}
|
||||
|
||||
resource "heroku_app" "metaforecast_backend" {
|
||||
name = "metaforecast-backend"
|
||||
region = "us"
|
||||
|
||||
config_vars = local.generated_env
|
||||
}
|
||||
|
||||
resource "vercel_project" "metaforecast" {
|
||||
name = "metaforecast"
|
||||
team_id = var.vercel_team
|
||||
|
@ -51,21 +73,12 @@ resource "vercel_env" "metaforecast" {
|
|||
project_id = vercel_project.metaforecast.id
|
||||
team_id = var.vercel_team
|
||||
type = "plain"
|
||||
for_each = var.metaforecast_env
|
||||
for_each = local.generated_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"]))
|
||||
|
|
|
@ -6,6 +6,10 @@ variable "digital_ocean_token" {
|
|||
type = string
|
||||
}
|
||||
|
||||
variable "heroku_api_key" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "vercel_team" {
|
||||
type = string
|
||||
default = "quantified-uncertainty"
|
||||
|
|
Loading…
Reference in New Issue
Block a user