-
Notifications
You must be signed in to change notification settings - Fork 108
/
registry.tf
65 lines (55 loc) · 1.6 KB
/
registry.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
/* Registry S3 bucket */
resource "aws_s3_bucket" "registry" {
bucket = "${var.s3_bucket_name}"
tags {
Name = "Docker Registry"
}
}
/* ELB for the registry */
resource "aws_elb" "s3-registry-elb" {
name = "s3-registry-elb"
availability_zones = ["${split(",", var.availability_zones)}"]
listener {
instance_port = 5000
instance_protocol = "http"
lb_port = 80
lb_protocol = "http"
}
/* @todo - handle SSL */
/*listener {
instance_port = 5000
instance_protocol = "http"
lb_port = 443
lb_protocol = "https"
ssl_certificate_id = "arn:aws:iam::123456789012:server-certificate/certName"
}*/
health_check {
healthy_threshold = 2
unhealthy_threshold = 2
timeout = 3
target = "HTTP:5000/"
interval = 30
}
connection_draining = false
tags {
Name = "s3-registry-elb"
}
}
/* container and task definitions for running the actual Docker registry */
resource "aws_ecs_service" "s3-registry-elb" {
name = "s3-registry-elb"
cluster = "${aws_ecs_cluster.default.id}"
task_definition = "${aws_ecs_task_definition.registry.arn}"
desired_count = 1
iam_role = "${aws_iam_role.ecs_role.arn}"
depends_on = ["aws_iam_role_policy.ecs_service_role_policy"]
load_balancer {
elb_name = "${aws_elb.s3-registry-elb.id}"
container_name = "registry"
container_port = 5000
}
}
resource "aws_ecs_task_definition" "registry" {
family = "registry"
container_definitions = "${template_file.registry_task.rendered}"
}