-
Notifications
You must be signed in to change notification settings - Fork 1
/
nyc_league.tf
119 lines (111 loc) · 3.21 KB
/
nyc_league.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
variable "nyc_league_version" {
default = "0.6.1"
}
resource "aws_route53_record" "nyc_league" {
zone_id = "${aws_route53_zone.root.zone_id}"
name = "nyc-league"
type = "A"
alias {
name = "${aws_alb.docker.dns_name}"
zone_id = "${aws_alb.docker.zone_id}"
evaluate_target_health = true
}
}
resource "aws_ecs_task_definition" "nyc_league" {
family = "nyc_league"
volume {
name = "nyc_league-uwsgi"
}
volume {
name = "nyc_league-db_data"
host_path = "/var/lib/nyc_league/db"
}
container_definitions = <<EOF
[
{
"name": "nyc_league_app",
"image": "${aws_ecr_repository.league_app.registry_id}.dkr.ecr.${var.region}.amazonaws.com/${aws_ecr_repository.league_app.name}:${var.nyc_league_version}",
"memoryReservation": 128,
"essential": true,
"links": ["nyc_league_db:db"],
"environment": [
{"name": "POSTGRES_USER", "value": "league"},
{"name": "POSTGRES_PASSWORD", "value": "league"},
{"name": "POSTGRES_DB", "value": "league"},
{"name": "SERVER_NAME", "value": "nyc-league.massgo.org"}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "${aws_cloudwatch_log_group.nyc_league.name}",
"awslogs-region": "${var.region}",
"awslogs-stream-prefix": "app"
}
},
"mountPoints": [
{
"sourceVolume": "nyc_league-uwsgi",
"containerPath": "/tmp/uwsgi"
}
]
},
{
"name": "league_webserver",
"image": "${aws_ecr_repository.league_webserver.registry_id}.dkr.ecr.${var.region}.amazonaws.com/${aws_ecr_repository.league_webserver.name}:${var.nyc_league_version}",
"environment": [
{ "name": "VIRTUAL_HOST", "value": "nyc-league.massgo.org"}
],
"essential": true,
"memoryReservation": 128,
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "${aws_cloudwatch_log_group.league.name}",
"awslogs-region": "${var.region}",
"awslogs-stream-prefix": "webserver"
}
},
"mountPoints": [
{
"sourceVolume": "nyc_league-uwsgi",
"containerPath": "/tmp/uwsgi"
}
]
},
{
"name": "nyc_league_db",
"image": "${aws_ecr_repository.league_db.registry_id}.dkr.ecr.${var.region}.amazonaws.com/${aws_ecr_repository.league_db.name}:${var.nyc_league_version}",
"essential": true,
"memoryReservation": 128,
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "${aws_cloudwatch_log_group.nyc_league.name}",
"awslogs-region": "${var.region}",
"awslogs-stream-prefix": "db"
}
},
"environment": [
{"name": "POSTGRES_USER", "value": "league"},
{"name": "POSTGRES_PASSWORD", "value": "league"},
{"name": "POSTGRES_DB", "value": "league"}
],
"mountPoints": [
{
"sourceVolume": "nyc_league-db_data",
"containerPath": "/var/lib/league/db"
}
]
}
]
EOF
}
resource "aws_ecs_service" "nyc_league" {
name = "nyc_league"
cluster = "${aws_ecs_cluster.docker.id}"
task_definition = "${aws_ecs_task_definition.nyc_league.arn}"
desired_count = 1
}
resource "aws_cloudwatch_log_group" "nyc_league" {
name = "nyc_league"
}