Skip to content

Commit

Permalink
Merge pull request eventuate-tram#13 from pranaysahith/master
Browse files Browse the repository at this point in the history
Add ALB to CDC and Customer service
  • Loading branch information
cer authored Jul 12, 2019
2 parents 715300b + 4419f0a commit 9e2c59f
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 179 deletions.
92 changes: 92 additions & 0 deletions aws-fargate-terraform/alb.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
resource "aws_alb" "lb_cdc" {
name = "lb-cdc"
subnets = ["${aws_subnet.public-subnet1.id}", "${aws_subnet.public-subnet2.id}"]
security_groups = ["${aws_security_group.sg-alb.id}"]
load_balancer_type = "application"
idle_timeout = 60
internal = false
enable_deletion_protection = false

tags {
Name = "CDC"
}
}

resource "aws_alb_listener" "cdc_listner" {
load_balancer_arn = "${aws_alb.lb_cdc.arn}"
port = 80
protocol = "HTTP"
depends_on = ["aws_alb_target_group.cdc_target_group", "aws_alb.lb_cdc"]

default_action {
target_group_arn = "${aws_alb_target_group.cdc_target_group.arn}"
type = "forward"
}
}

resource "aws_alb_target_group" "cdc_target_group" {
name = "cdc-target-group"
port = 8080
protocol = "HTTP"
vpc_id = "${aws_vpc.vpc-eventuate.id}"
target_type = "ip"

lifecycle {
create_before_destroy = true
}

health_check {
healthy_threshold = 2
path = "/actuator/health"
timeout = 10
interval = 30
port = "8080"
}
}

resource "aws_alb" "lb_customer" {
name = "lb-customer"
subnets = ["${aws_subnet.public-subnet2.id}", "${aws_subnet.public-subnet1.id}"]
security_groups = ["${aws_security_group.sg-alb.id}"]
load_balancer_type = "application"
idle_timeout = 60
internal = false
enable_deletion_protection = false

tags {
Name = "customer_elb"
}

}

resource "aws_alb_listener" "customer_listner" {
load_balancer_arn = "${aws_alb.lb_customer.arn}"
port = 80
protocol = "HTTP"
depends_on = ["aws_alb_target_group.customer_target_group"]

default_action {
target_group_arn = "${aws_alb_target_group.customer_target_group.arn}"
type = "forward"
}
}

resource "aws_alb_target_group" "customer_target_group" {
name = "customer-target-group"
port = 8080
protocol = "HTTP"
vpc_id = "${aws_vpc.vpc-eventuate.id}"
target_type = "ip"

lifecycle {
create_before_destroy = true
}

health_check {
healthy_threshold = 2
path = "/actuator/health"
timeout = 30
interval = 60
port = "8080"
}
}
11 changes: 9 additions & 2 deletions aws-fargate-terraform/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ resource "aws_ecs_service" "svc_cdc" {
desired_count = 1

depends_on = [
"aws_iam_role_policy.ecs_service_role_policy",
"aws_iam_role_policy.ecs_service_role_policy", "aws_alb_listener.cdc_listner"
]

lifecycle {
Expand All @@ -27,12 +27,19 @@ resource "aws_ecs_service" "svc_cdc" {
]

subnets = [
"${aws_subnet.public-subnet.id}",
"${aws_subnet.public-subnet1.id}",
"${aws_subnet.public-subnet2.id}",
]

assign_public_ip = true
}

load_balancer {
container_name = "cdcservice"
container_port = 8080
target_group_arn = "${aws_alb_target_group.cdc_target_group.arn}"
}
health_check_grace_period_seconds = 120
}

data "template_file" "cdc_task_definition" {
Expand Down
4 changes: 2 additions & 2 deletions aws-fargate-terraform/ecs_cdc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"containerPort": 8099
},
{
"hostPort": 8088,
"hostPort": 8080,
"protocol": "tcp",
"containerPort": 8088
"containerPort": 8080
}
],
"environment": [
Expand Down
7 changes: 7 additions & 0 deletions aws-fargate-terraform/ecs_customer_definition.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
"awslogs-stream-prefix": "ecs"
}
},
"portMappings": [
{
"hostPort": 8080,
"protocol": "tcp",
"containerPort": 8080
}
],
"environment": [
{
"name": "JAVA_OPTS",
Expand Down
11 changes: 9 additions & 2 deletions aws-fargate-terraform/ecs_customer_service.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ resource "aws_ecs_service" "svc_customer" {
desired_count = 1

depends_on = [
"aws_iam_role_policy.ecs_service_role_policy",
"aws_iam_role_policy.ecs_service_role_policy","aws_alb_listener.customer_listner"
]

lifecycle {
Expand All @@ -23,12 +23,19 @@ resource "aws_ecs_service" "svc_customer" {
]

subnets = [
"${aws_subnet.public-subnet.id}",
"${aws_subnet.public-subnet1.id}",
"${aws_subnet.public-subnet2.id}",
]

assign_public_ip = true
}

load_balancer {
container_name = "customer"
container_port = 8080
target_group_arn = "${aws_alb_target_group.customer_target_group.arn}"
}
health_check_grace_period_seconds = 120
}

data "template_file" "customer_task_definition" {
Expand Down
162 changes: 0 additions & 162 deletions aws-fargate-terraform/ecs_definition.json

This file was deleted.

10 changes: 8 additions & 2 deletions aws-fargate-terraform/kafka.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ resource "aws_msk_cluster" "eventuate" {

client_subnets = [
"${aws_subnet.public-subnet1.id}",
"${aws_subnet.public-subnet.id}",
"${aws_subnet.public-subnet2.id}",
"${aws_subnet.public-subnet3.id}"
]

security_groups = ["${aws_security_group.kafka.id}"]
security_groups = ["${aws_security_group.sg_kafka.id}"]
}

encryption_info {
Expand Down Expand Up @@ -56,3 +56,9 @@ output "bootstrap_brokers_tls" {
description = "TLS connection host:port pairs"
value = "${aws_msk_cluster.eventuate.bootstrap_brokers_tls}"
}

output "bootstrap_brokers" {
description = "TLS connection host:port pairs"
value = "${aws_msk_cluster.eventuate.bootstrap_brokers}"
}

Loading

0 comments on commit 9e2c59f

Please sign in to comment.