-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.tf
130 lines (102 loc) · 3.28 KB
/
main.tf
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
#####################################
############# PROVIDERS #############
#####################################
# We need the Heroku provider in order to create the Heroku application
provider "heroku" {
email = "${var.heroku_email}"
api_key = "${var.heroku_api_key}"
}
# We need the AWS provider in order to create the S3 bucket
provider "aws" {
access_key = "${var.aws_access_key}"
secret_key = "${var.aws_secret_key}"
region = "${var.aws_region}"
}
#####################################
########## HEROKU PIPELINE ##########
#####################################
module "heroku_pipeline" {
source = "./modules/heroku_pipeline"
pipeline_name = "${var.app_name}"
}
#####################################
########### STAGING ENV #############
#####################################
module "cdn_staging" {
source = "./modules/aws_cdn"
app_name = "${var.app_name}"
# hard-coded madness
domain_name = "${var.app_name}-staging.herokuapp.com"
app_environment = "staging"
}
module "s3_staging" {
source = "./modules/aws_s3_bucket"
app_name = "${var.app_name}"
app_environment = "staging"
s3_bucket = "${var.app_name}-dev"
}
module "heroku_staging" {
source = "./modules/heroku_app"
# App settings
app_name = "${var.app_name}-staging"
app_environment = "staging"
app_region = "${var.heroku_app_region}"
# S3 settings
s3_bucket = "${module.s3_staging.name}"
s3_access_key = "${module.s3_staging.access_key}"
s3_secret_key = "${module.s3_staging.secret_key}"
cdn_domain = "${module.cdn_staging.domain_name}"
}
module "papertrail" {
source = "./modules/heroku_addon"
# Addon settings
app_name = "${module.heroku_staging.name}"
addon_plan = "papertrail:fixa"
}
#####################################
########## PRODUCTION ENV ###########
#####################################
module "cdn_prod" {
source = "./modules/aws_cdn"
app_name = "${var.app_name}"
domain_name = "${var.app_url}"
app_environment = "prod"
}
module "s3_prod" {
source = "./modules/aws_s3_bucket"
app_name = "${var.app_name}"
app_environment = "prod"
s3_bucket = "${var.app_name}"
}
module "heroku_prod" {
source = "./modules/heroku_app"
# App settings
app_name = "${var.app_name}-prod"
app_environment = "prod"
app_region = "${var.heroku_app_region}"
# S3 settings
s3_bucket = "${module.s3_prod.name}"
s3_access_key = "${module.s3_prod.access_key}"
s3_secret_key = "${module.s3_prod.secret_key}"
cdn_domain = "${module.cdn_prod.domain_name}"
}
module "papertrail_attachment" {
source = "./modules/heroku_addon_attachment"
app_id = "${module.heroku_prod.id}"
addon_id = "${module.papertrail.id}"
name = "PAPERTRAIL"
}
module "custom_domain" {
source = "./modules/heroku_domain"
app_name = "${module.heroku_prod.name}"
hostname = "${var.app_url}"
}
#####################################
###### HEROKU PIPELINE COUPLING #####
#####################################
module "heroku_pipeline_coupling" {
source = "./modules/heroku_pipeline_coupling"
pipeline_id = "${module.heroku_pipeline.id}"
staging_app = "${module.heroku_staging.name}"
prod_app = "${module.heroku_prod.name}"
}