Initial commit: Terraform configurations for multiple cloud providers
This commit is contained in:
99
heroku/main.tf
Normal file
99
heroku/main.tf
Normal file
@@ -0,0 +1,99 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
heroku = {
|
||||
source = "heroku/heroku"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "heroku" {
|
||||
email = var.heroku_email
|
||||
api_key = var.heroku_api_key
|
||||
}
|
||||
|
||||
variable "heroku_api_key" {
|
||||
description = "Heroku API Key"
|
||||
type = string
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
variable "heroku_email" {
|
||||
description = "Heroku Email"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "app_name" {
|
||||
description = "Heroku App Name"
|
||||
type = string
|
||||
default = "terraform-app"
|
||||
}
|
||||
|
||||
variable "region" {
|
||||
description = "Heroku Region"
|
||||
type = string
|
||||
default = "us"
|
||||
}
|
||||
|
||||
variable "stack" {
|
||||
description = "Heroku Stack"
|
||||
type = string
|
||||
default = "heroku-22"
|
||||
}
|
||||
|
||||
variable "dyno_size" {
|
||||
description = "Dyno Size"
|
||||
type = string
|
||||
default = "basic"
|
||||
}
|
||||
|
||||
resource "heroku_app" "main" {
|
||||
name = var.app_name
|
||||
region = var.region
|
||||
stack = var.stack
|
||||
}
|
||||
|
||||
resource "heroku_formation" "web" {
|
||||
app_id = heroku_app.main.id
|
||||
type = "web"
|
||||
quantity = 1
|
||||
size = var.dyno_size
|
||||
}
|
||||
|
||||
resource "heroku_addon" "postgres" {
|
||||
app_id = heroku_app.main.id
|
||||
plan = "heroku-postgresql:essential-0"
|
||||
}
|
||||
|
||||
resource "heroku_addon" "redis" {
|
||||
app_id = heroku_app.main.id
|
||||
plan = "heroku-redis:mini"
|
||||
}
|
||||
|
||||
resource "heroku_config" "app_config" {
|
||||
sensitive_vars = {
|
||||
NODE_ENV = "production"
|
||||
PORT = "8080"
|
||||
}
|
||||
}
|
||||
|
||||
output "app_url" {
|
||||
description = "Heroku App URL"
|
||||
value = "https://${var.app_name}.herokuapp.com"
|
||||
}
|
||||
|
||||
output "app_name" {
|
||||
description = "Heroku App Name"
|
||||
value = heroku_app.main.name
|
||||
}
|
||||
|
||||
output "postgres_url" {
|
||||
description = "PostgreSQL Database URL"
|
||||
value = heroku_addon.postgres.config_var_values
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
output "redis_url" {
|
||||
description = "Redis URL"
|
||||
value = heroku_addon.redis.config_var_values
|
||||
sensitive = true
|
||||
}
|
||||
Reference in New Issue
Block a user