Skip to content

Commit

Permalink
Merge pull request #6145 from spicysomtam/support-task-dynamic-host-p…
Browse files Browse the repository at this point in the history
…ort-mapping

Allow ecs task dynamic host port mapping.
  • Loading branch information
bflad authored Oct 14, 2018
2 parents efcbb7c + 9966f13 commit 14d0bc4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions examples/ecs-alb/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ resource "aws_security_group" "instance_sg" {

ingress {
protocol = "tcp"
from_port = 8080
to_port = 8080
from_port = 32768
to_port = 61000

security_groups = [
"${aws_security_group.lb_sg.id}",
Expand Down Expand Up @@ -185,7 +185,7 @@ resource "aws_ecs_service" "test" {
name = "tf-example-ecs-ghost"
cluster = "${aws_ecs_cluster.main.id}"
task_definition = "${aws_ecs_task_definition.ghost.arn}"
desired_count = 1
desired_count = "${var.service_desired}"
iam_role = "${aws_iam_role.ecs_service.name}"

load_balancer {
Expand Down
2 changes: 1 addition & 1 deletion examples/ecs-alb/task-definition.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"portMappings": [
{
"containerPort": 2368,
"hostPort": 8080
"hostPort": 0
}
],
"logConfiguration": {
Expand Down
5 changes: 5 additions & 0 deletions examples/ecs-alb/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ variable "asg_desired" {
default = "1"
}

variable "service_desired" {
description = "Desired numbers of instances in the ecs service"
default = "1"
}

variable "admin_cidr_ingress" {
description = "CIDR to allow tcp/22 ingress to EC2 instance"
}

0 comments on commit 14d0bc4

Please sign in to comment.