This repository has been archived by the owner on Nov 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
57 lines (50 loc) · 1.44 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
locals {
# Variable defaults cannot be directly based on other variables
storage_bucket_name = coalesce(var.assetstore_bucket_name, "${var.project_slug}-assetstore")
}
module "server" {
source = "./modules/server"
project_slug = var.project_slug
ec2_instance_type = var.ec2_instance_type
ec2_volume_size = var.ec2_volume_size
ssh_public_key = var.ssh_public_key
ec2_launch_ami_id = var.ec2_launch_ami_id
}
resource "aws_route53_record" "server" {
zone_id = var.route53_zone_id
name = var.subdomain_name
type = "A"
ttl = "300"
records = [module.server.ec2_ip]
}
module "assetstore" {
source = "./modules/assetstore"
bucket_name = local.storage_bucket_name
upload_origins = concat(
["https://${aws_route53_record.server.fqdn}"],
var.extra_upload_origins
)
}
resource "aws_iam_role_policy" "server_assetstore" {
name = "${var.project_slug}-assetstore-access"
role = module.server.ec2_iam_role_id
policy = data.aws_iam_policy_document.server_assetstore.json
}
data "aws_iam_policy_document" "server_assetstore" {
statement {
actions = [
"s3:*",
]
resources = [
module.assetstore.bucket_arn,
"${module.assetstore.bucket_arn}/*",
]
}
}
module "smtp" {
source = "kitware-resonant/resonant/heroku//modules/smtp"
version = "1.1.1"
project_slug = var.project_slug
route53_zone_id = var.route53_zone_id
fqdn = aws_route53_record.server.fqdn
}