Skip to content

Commit

Permalink
ECS with ELB not possible due to hashicorp/terraform#5442
Browse files Browse the repository at this point in the history
  • Loading branch information
graphenic-bot2 committed Mar 3, 2016
1 parent d91d9e5 commit bcd7c63
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 56 deletions.
108 changes: 54 additions & 54 deletions ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,66 +48,66 @@ resource "aws_ecs_service" "pdat-ecs-service" {
cluster = "${aws_ecs_cluster.pdat-ecs-cluster.id}"
task_definition = "${aws_ecs_task_definition.pdat-ecs-wordpress.arn}"
desired_count = 1
iam_role = "${aws_iam_role.pdat-ecs-role.id}"

load_balancer {
elb_name = "${aws_elb.pdat-elb.id}"
container_name = "${var.container_name}"
container_port = 80
}

depends_on = ["aws_iam_role.pdat-ecs-role","aws_instance.pdat-ecs-instance"]

}
// iam_role = "${aws_iam_role.pdat-ecs-role.arn}"
//
// load_balancer {
// elb_name = "${aws_elb.pdat-elb.id}"
// container_name = "${var.container_name}"
// container_port = 80
// }

// depends_on = ["aws_elb.pdat-elb","aws_iam_role.pdat-ecs-role","aws_iam_role_policy.pdat-ecs-policy","aws_instance.pdat-ecs-instance"]


// Create ELB

resource "aws_s3_bucket" "pdat-elb-s3" {
bucket = "pdat-elb-logs"
acl = "private"

tags {
Name = "pdat-elb-s3"
}
}

resource "aws_elb" "pdat-elb" {
name = "pdat-elb"
availability_zones = [
"us-east-1b"]

access_logs {
bucket = "elb-logs"
bucket_prefix = "pdat_"
interval = 60
}

listener {
instance_port = 80
instance_protocol = "http"
lb_port = 80
lb_protocol = "http"
}

health_check {
healthy_threshold = 2
unhealthy_threshold = 2
timeout = 3
target = "HTTP:80/"
interval = 30
}

cross_zone_load_balancing = false
idle_timeout = 400
connection_draining = false

tags {
Name = "pdat_elb"
}
}
//// Create ELB
//
//resource "aws_s3_bucket" "pdat-elb-s3" {
// bucket = "pdat-elb-logs"
// acl = "private"
//
// tags {
// Name = "pdat-elb-s3"
// }
//}
//
//resource "aws_elb" "pdat-elb" {
// name = "pdat-elb"
// availability_zones = [
// "us-east-1b"]
//
// access_logs {
// bucket = "elb-logs"
// bucket_prefix = "pdat_"
// interval = 60
// }
//
// listener {
// instance_port = 8080
// instance_protocol = "http"
// lb_port = 80
// lb_protocol = "http"
// }
//
// health_check {
// healthy_threshold = 2
// unhealthy_threshold = 2
// timeout = 3
// target = "HTTP:80/"
// interval = 30
// }
//
// cross_zone_load_balancing = false
// idle_timeout = 400
// connection_draining = false
//
// tags {
// Name = "pdat_elb"
// }
//}

output "public EIP" {
value = "${aws_instance.pdat-ecs-instance.public_ip}"
}
}
4 changes: 2 additions & 2 deletions iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ resource "aws_iam_instance_profile" "pdat-ecs-profile" {

resource "aws_iam_role_policy" "pdat-ecs-policy" {
name = "pdat-ecs-policy"
role = "${aws_iam_role.pdat-ecs-role.id}"
role = "${aws_iam_role.pdat-ecs-role.name}"
policy = <<EOF
{
"Version": "2012-10-17",
Expand Down Expand Up @@ -39,7 +39,7 @@ resource "aws_iam_instance_profile" "pdat-ecs-profile" {
}
EOF

depends_on = ["aws_iam_role.pdat-ecs-role"]
// depends_on = ["aws_iam_role.pdat-ecs-role"]
}

resource "aws_iam_role" "pdat-ecs-role" {
Expand Down
8 changes: 8 additions & 0 deletions vpc.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ resource "aws_security_group" "pdat-security-group" {
cidr_blocks = ["0.0.0.0/0"]
}

ingress {
from_port = 8080
to_port = 8080
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}


ingress {
from_port = 443
to_port = 443
Expand Down

0 comments on commit bcd7c63

Please sign in to comment.