Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ resource "aws_iam_role_policy" "scheduled_task_cloudwatch_policy" {
resource "aws_ecs_task_definition" "scheduled_task" {
family = "${var.name}-${var.environment}-scheduled-task"
container_definitions = "${var.container_definitions}"
requires_compatibilities = ["EC2"]
requires_compatibilities = ["${var.launch_type}"]
network_mode = "${var.network_mode}"
execution_role_arn = "${aws_iam_role.scheduled_task_ecs_execution.arn}"
task_role_arn = "${aws_iam_role.scheduled_task_ecs.arn}"
Expand All @@ -73,5 +73,12 @@ resource "aws_cloudwatch_event_target" "scheduled_task" {
ecs_target {
task_count = "${var.task_count}"
task_definition_arn = "${aws_ecs_task_definition.scheduled_task.arn}"
launch_type = "${var.launch_type}"

network_configuration {
subnets = ["${var.subnets}"]
security_groups = ["${var.security_groups}"]
assign_public_ip = "${var.assign_public_ip}"
}
}
}
32 changes: 26 additions & 6 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ variable "environment" {
description = "Environment - appended to ${var.name} for resources"
}

variable "network_mode" {
type = "string"
description = "Task network mode"
default = "bridge"
}

variable "container_definitions" {
type = "string"
description = "Task container defintions"
Expand Down Expand Up @@ -44,3 +38,29 @@ variable "memory" {
type = "string"
description = "The amount (in MiB) of memory used by the task"
}

variable "network_mode" {
type = "string"
description = "Task network mode"
default = "bridge"
}

variable "launch_type" {
description = "Launch type on which your task is running. Valid values are EC2 or FARGATE."
default = "EC2"
}

variable "subnets" {
description = "List of subnets if network_mode is `awsvpc`"
default = []
}

variable "security_groups" {
description = "List of security groups if network_mode is `awsvpc`"
default = []
}

variable "assign_public_ip" {
description = "Assign a public IP to the ENI (Fargate launch type only)"
default = false
}