ops: domain, .env generator
This commit is contained in:
		
							parent
							
								
									5cf183ec6f
								
							
						
					
					
						commit
						5f19ff1c98
					
				
							
								
								
									
										1
									
								
								tf/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								tf/.gitignore
									
									
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -1,2 +1,3 @@
 | 
			
		|||
/*.tfstate*
 | 
			
		||||
/.terraform*
 | 
			
		||||
/prod.tfvars
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										33
									
								
								tf/main.tf
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								tf/main.tf
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -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
									
								
							
							
						
						
									
										7
									
								
								tf/variables.tf
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,7 @@
 | 
			
		|||
variable "metaforecast_env" {
 | 
			
		||||
  type = map(string)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
variable "vercel_api_token" {
 | 
			
		||||
  type = string
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user