ops: domain, .env generator

This commit is contained in:
Vyacheslav Matyukhin 2022-04-11 22:38:00 +03:00
parent 5cf183ec6f
commit 5f19ff1c98
No known key found for this signature in database
GPG Key ID: 3D2A774C5489F96C
3 changed files with 32 additions and 9 deletions

1
tf/.gitignore vendored
View File

@ -1,2 +1,3 @@
/*.tfstate*
/.terraform*
/prod.tfvars

View File

@ -4,30 +4,45 @@ terraform {
source = "vercel/vercel"
version = "~> 0.1"
}
local = {
source = "hashicorp/local"
version = "~> 2"
}
}
}
provider "vercel" {
# Or omit this for the api_token to be read
# from the VERCEL_API_TOKEN environment variable
# api_token = var.vercel_api_token
api_token = var.vercel_api_token
}
resource "vercel_project" "with_git" {
name = "metaforecast-test"
resource "vercel_project" "metaforecast" {
name = "metaforecast"
team_id = "quantified-uncertainty"
framework = "nextjs"
environment = [
{
key = "NEXT_PUBLIC_ALGOLIA_APP_ID"
value = "96UD3NTQ7L"
for k, v in var.metaforecast_env : {
key = k
value = v
target = ["production"]
}
]
git_repository = {
type = "github"
repo = "berekuk/metaforecast"
repo = "QURIresearch/metaforecast"
}
}
resource "vercel_project_domain" "metaforecast" {
project_id = vercel_project.metaforecast.id
domain = "metaforecast.org"
team_id = "quantified-uncertainty"
}
// 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"
}

7
tf/variables.tf Normal file
View File

@ -0,0 +1,7 @@
variable "metaforecast_env" {
type = map(string)
}
variable "vercel_api_token" {
type = string
}