-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathevening_league.tf
126 lines (118 loc) · 3.44 KB
/
evening_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
120
121
122
123
124
125
126
variable "evening_league_version" {
default = "0.5.1"
}
resource "aws_route53_record" "evening_league" {
zone_id = "${aws_route53_zone.root.zone_id}"
name = "evening-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" "evening_league" {
family = "evening_league"
volume {
name = "evening_league-uwsgi"
}
volume {
name = "evening_league-db_data"
host_path = "/var/lib/evening_league/db"
}
container_definitions = <<EOF
[
{
"name": "evening_league_app",
"image": "${aws_ecr_repository.league_app.registry_id}.dkr.ecr.${var.region}.amazonaws.com/${aws_ecr_repository.league_app.name}:${var.evening_league_version}",
"essential": true,
"links": ["evening_league_db:db"],
"memoryReservation": 128,
"environment": [
{"name": "POSTGRES_USER", "value": "league"},
{"name": "POSTGRES_PASSWORD", "value": "league"},
{"name": "POSTGRES_DB", "value": "league"},
{"name": "SERVER_NAME", "value": "evening-league.massgo.org"}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "${aws_cloudwatch_log_group.evening_league.name}",
"awslogs-region": "${var.region}",
"awslogs-stream-prefix": "app"
}
},
"mountPoints": [
{
"sourceVolume": "evening_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.evening_league_version}",
"environment": [
{ "name": "VIRTUAL_HOST", "value": "evening-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": "evening_league-uwsgi",
"containerPath": "/tmp/uwsgi"
}
]
},
{
"name": "evening_league_db",
"image": "${aws_ecr_repository.league_db.registry_id}.dkr.ecr.${var.region}.amazonaws.com/${aws_ecr_repository.league_db.name}:${var.evening_league_version}",
"essential": true,
"memoryReservation": 128,
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "${aws_cloudwatch_log_group.evening_league.name}",
"awslogs-region": "${var.region}",
"awslogs-stream-prefix": "db"
}
},
"portMappings": [
{
"hostPort": 5433,
"containerPort": 5432,
"protocol": "tcp"
}
],
"environment": [
{"name": "POSTGRES_USER", "value": "league"},
{"name": "POSTGRES_PASSWORD", "value": "league"},
{"name": "POSTGRES_DB", "value": "league"}
],
"mountPoints": [
{
"sourceVolume": "evening_league-db_data",
"containerPath": "/var/lib/league/db"
}
]
}
]
EOF
}
resource "aws_ecs_service" "evening_league" {
name = "evening_league"
cluster = "${aws_ecs_cluster.docker.id}"
task_definition = "${aws_ecs_task_definition.evening_league.arn}"
desired_count = 1
}
resource "aws_cloudwatch_log_group" "evening_league" {
name = "evening_league"
}