-
Notifications
You must be signed in to change notification settings - Fork 3
/
dev_pah_fm.tf
145 lines (121 loc) · 3.66 KB
/
dev_pah_fm.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
module "dev_pah_fm_user" {
source = "./user"
name = "dev_pah_fm"
}
module "dev_pah_fm_db" {
source = "./database"
name = "dev_pah_fm"
db_instance = aws_db_instance.db
}
resource "random_password" "dev_pah_fm_secret_key" {
length = 50
special = false
}
module "dev_pah_fm_migration" {
source = "./lambda"
name = "dev_pah_fm_migration"
runtime = "python3.10"
handler = "handlers.migration"
s3_bucket = aws_s3_bucket.codeforpoznan_lambdas
iam_user = module.dev_pah_fm_user.user
user_can_invoke = true
subnets = [
aws_subnet.private_a,
aws_subnet.private_b,
aws_subnet.private_c,
]
security_groups = [
aws_default_security_group.main
]
envvars = {
PAH_FM_DB_USER = module.dev_pah_fm_db.user.name
PAH_FM_DB_NAME = module.dev_pah_fm_db.database.name
PAH_FM_DB_PASS = module.dev_pah_fm_db.password.result
PAH_FM_DB_HOST = aws_db_instance.db.address
BASE_URL = "dev.pahfm.codeforpoznan.pl"
SECRET_KEY = random_password.dev_pah_fm_secret_key.result
}
}
module "dev_pah_fm_ssl_certificate" {
source = "./ssl_certificate"
domain = "dev.pahfm.codeforpoznan.pl"
route53_zone = aws_route53_zone.codeforpoznan_pl
providers = {
aws = aws.north_virginia
}
}
module "dev_pah_fm_frontend_assets" {
source = "./frontend_assets"
name = "dev_pah_fm"
s3_bucket = aws_s3_bucket.codeforpoznan_public
iam_user = module.dev_pah_fm_user.user
}
module "dev_pah_fm_serverless_api" {
source = "./serverless_api"
name = "dev_pah_fm"
runtime = "python3.10"
handler = "handlers.api"
s3_bucket = aws_s3_bucket.codeforpoznan_lambdas
iam_user = module.dev_pah_fm_user.user
subnets = [
aws_subnet.private_a,
aws_subnet.private_b,
aws_subnet.private_c,
]
security_groups = [
aws_default_security_group.main
]
envvars = {
PAH_FM_DB_USER = module.dev_pah_fm_db.user.name
PAH_FM_DB_NAME = module.dev_pah_fm_db.database.name
PAH_FM_DB_PASS = module.dev_pah_fm_db.password.result
PAH_FM_DB_HOST = aws_db_instance.db.address
BASE_URL = "dev.pahfm.codeforpoznan.pl"
SECRET_KEY = random_password.dev_pah_fm_secret_key.result
STRIP_STAGE_PATH = "yes"
}
}
module "dev_pah_fm_cloudfront_distribution" {
source = "./cloudfront_distribution"
name = "dev_pah_fm"
domain = "dev.pahfm.codeforpoznan.pl"
s3_bucket = aws_s3_bucket.codeforpoznan_public
route53_zone = aws_route53_zone.codeforpoznan_pl
iam_user = module.dev_pah_fm_user.user
acm_certificate = module.dev_pah_fm_ssl_certificate.certificate
origins = {
static_assets = {
default = true
domain_name = aws_s3_bucket.codeforpoznan_public.bucket_domain_name
origin_path = "/dev_pah_fm"
}
api_gateway = {
domain_name = regex("https://(?P<hostname>[^/?#]*)(?P<path>[^?#]*)", module.dev_pah_fm_serverless_api.deployment.invoke_url).hostname
origin_path = regex("https://(?P<hostname>[^/?#]*)(?P<path>[^?#]*)", module.dev_pah_fm_serverless_api.deployment.invoke_url).path
custom_origin = true
}
}
additional_cache_behaviors = [
{
path_pattern = "api/*"
target_origin_id = "api_gateway"
headers = ["Authorization"]
max_ttl = 0
default_ttl = 0
},
{
path_pattern = "admin/*"
target_origin_id = "api_gateway"
headers = ["Referer"]
max_ttl = 0
default_ttl = 0
}
]
custom_error_responses = [
{
error_code = 404
response_code = 200
response_page_path = "/index.html"
}
]
}