Skip to content

Instantly share code, notes, and snippets.

@deinarson
Created December 9, 2015 00:43
Show Gist options
  • Save deinarson/e0b168036f0892f57cab to your computer and use it in GitHub Desktop.
Save deinarson/e0b168036f0892f57cab to your computer and use it in GitHub Desktop.
############################################
# ECS and S3
############################################
resource "aws_elb" "s3-registry-elb" {
name = "s3-registry-elb"
availability_zones = ["${split(",", var.availability_zones)}"]
security_groups = ["${aws_security_group.ecs.id}"]
subnets = ["${module.vpc.private_subnets}"]
listener {
instance_port = 8080
instance_protocol = "http"
lb_port = 80
lb_protocol = "http"
}
/* @todo - handle SSL */
/*listener {
instance_port = 8080
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:8080/"
interval = 30
}
connection_draining = false
tags {
Name = "s3-registry-elb"
}
}
resource "aws_ecs_cluster" "docker_cluster" {
name = "docker_cluster"
}
/* 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.docker_cluster.id}"
task_definition = "${aws_ecs_task_definition.registry.arn}"
desired_count = 1
iam_role = "${aws_iam_role.role.arn}"
depends_on = ["aws_iam_role_policy.ecs_docker_registry_instance_role_policy"]
load_balancer {
elb_name = "${aws_elb.s3-registry-elb.id}"
container_name = "registry"
container_port = 8080
}
}
resource "aws_ecs_task_definition" "registry" {
family = "registry"
container_definitions = "${template_file.registry_task.rendered}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment