Skip to content

Commit

Permalink
Add support for specific container name (#17)
Browse files Browse the repository at this point in the history
* Added service name output.
Introduced new optional input to specify container name explicitly,

* Added support for overriding container name in task definition

* Setting name_prefix as task id

* Removed task definition id

* Formatting

* Fixed typo

* Added variables for overriding container name

* Reintroduced container name support without explicit flag.
  • Loading branch information
austpaul authored and Kristian committed Jul 16, 2019
1 parent f9d7236 commit eb1a320
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ resource "aws_ecs_task_definition" "task" {

container_definitions = <<EOF
[{
"name": "${var.name_prefix}",
"name": "${var.container_name != "" ? var.container_name : var.name_prefix}",
"image": "${var.task_container_image}",
${local.repository_credentials_rendered}
"essential": true,
Expand Down Expand Up @@ -154,7 +154,7 @@ resource "aws_ecs_service" "service" {
}

load_balancer {
container_name = "${var.name_prefix}"
container_name = "${var.container_name != "" ? var.container_name : var.name_prefix}"
container_port = "${var.task_container_port}"
target_group_arn = "${aws_lb_target_group.task.arn}"
}
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ variable "name_prefix" {
description = "A prefix used for naming resources."
}

variable "container_name" {
description = "Optional name for the container to be used instead of name_prefix. Useful when when constructing an imagedefinitons.json file for continuous deployment using Codepipeline."
default = ""
}

variable "vpc_id" {
description = "The VPC ID."
}
Expand Down

0 comments on commit eb1a320

Please sign in to comment.