This repository was archived by the owner on Jan 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_heroku.tf
More file actions
138 lines (113 loc) · 3.19 KB
/
api_heroku.tf
File metadata and controls
138 lines (113 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# Configure the Heroku provider
##
# 1. Variables
##
variable "heroku_email" {
type = "string"
description = "Your Heroku Email"
}
variable "heroku_api_key" {
type = "string"
description = "Your Heroku API key (find it in your Heroku account settings)"
}
variable "heroku_team" {
type = "string"
description = "Name of the Team (must already exist)"
}
variable "app_name" {
type = "string"
description = "Your app's name. Name must start with a letter, end with a letter or digit and can only contain lowercase letters, digits, and dashes."
}
variable "bible_api_key" {
type = "string"
default = ""
description = "Optional Bible.API key. Use if you render scripture."
}
variable "engine_api_key" {
type = "string"
default = ""
description = "Optional Apollo Engine API Key. Apollo Engine is an APM for GraphQL services."
}
variable "rock_token" {
type = "string"
default = ""
description = "Your Rock Token. See apollos-data documentation for required permissions."
}
variable "one_signal_rest_key" {
type = "string"
default = ""
description = "Optional OneSignal rest key. Use if you utilize OneSignal for sending push notifications."
}
provider "heroku" {
email = "${var.heroku_email}"
api_key = "${var.heroku_api_key}"
}
##
# 2. Create Heroku apps for staging and production
##
resource "heroku_app" "staging" {
region = "us"
name = "${var.app_name}-staging"
config_vars {
BIBLE_API_KEY = "${var.bible_api_key}"
ENGINE_API_KEY = "${var.engine_api_key}"
ROCK_TOKEN = "${var.rock_token}"
ONE_SIGNAL_REST_KEY = "${var.one_signal_rest_key}"
}
organization = {
name = "${var.heroku_team}"
}
stack = "container"
}
resource "heroku_app" "production" {
region = "us"
name = "${var.app_name}-production"
config_vars {
BIBLE_API_KEY = "${var.bible_api_key}"
ENGINE_API_KEY = "${var.engine_api_key}"
ROCK_TOKEN = "${var.rock_token}"
ONE_SIGNAL_REST_KEY = "${var.one_signal_rest_key}"
}
organization = {
name = "${var.heroku_team}"
}
stack = "container"
}
##
# 3. Create a Heroku Pipeline
##
resource "heroku_pipeline" "pipeline" {
name = "${var.app_name}"
}
# Couple apps to different pipeline stages
resource "heroku_pipeline_coupling" "staging" {
app = "${heroku_app.staging.name}"
pipeline = "${heroku_pipeline.pipeline.id}"
stage = "staging"
}
resource "heroku_pipeline_coupling" "production" {
app = "${heroku_app.production.name}"
pipeline = "${heroku_pipeline.pipeline.id}"
stage = "production"
}
##
# 4, Provision Heroku addons
##
resource "heroku_addon" "cloudinary-staging" {
app = "${heroku_app.staging.name}"
plan = "cloudinary"
}
resource "heroku_addon" "cloudinary-production" {
app = "${heroku_app.production.name}"
plan = "cloudinary"
}
# Comment out the following lines to enable CDN creation
# https://elements.heroku.com/addons/fastly
# resource "heroku_addon" "fastly-staging" {
# app = "${heroku_app.staging.name}"
# plan = "fastly:quick"
# }
resource "heroku_addon" "fastly-production" {
app = "${heroku_app.production.name}"
plan = "fastly:quick"
}