Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ✨ added restart policies #192

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion examples/complete/fixtures.us-east-2.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ container_memory_reservation = 128
container_cpu = 256
essential = true
readonly_root_filesystem = false
restart_policy = {
enabled = true
ignoredExitCodes = [0]
}

container_environment = [
{
Expand Down Expand Up @@ -70,4 +74,4 @@ extra_hosts = [

hostname = "hostname"
pseudo_terminal = true
interactive = true
interactive = true
1 change: 1 addition & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module "container" {
hostname = var.hostname
pseudo_terminal = var.pseudo_terminal
interactive = var.interactive
restart_policy = var.restart_policy
}

resource "aws_ecs_task_definition" "task" {
Expand Down
10 changes: 10 additions & 0 deletions examples/complete/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,13 @@ variable "docker_security_options" {
description = "A list of strings to provide custom labels for SELinux and AppArmor multi-level security systems."
default = null
}

variable "restart_policy" {
type = object({
enabled = optional(bool)
ignoredExitCodes = optional(list(number))
restartAttemptPeriod = optional(number)
})
description = "Container restart policy. Used to restart (rather than reprovision) a container when it exits unexpectedly"
default = null
}
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ locals {
pseudoTerminal = var.pseudo_terminal
dockerSecurityOptions = var.docker_security_options
resourceRequirements = var.resource_requirements
restartPolicy = var.restart_policy
}

container_definition_without_null = {
Expand Down
15 changes: 15 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ variable "container_definition" {
sourceContainer = string
})))
workingDirectory = optional(string)
restartPolicy = optional(object({
enabled = optional(bool)
ignoredExitCodes = optional(list(number))
restartAttemptPeriod = optional(number)
}))
})
description = "Container definition overrides which allows for extra keys or overriding existing keys."
default = {}
Expand Down Expand Up @@ -453,3 +458,13 @@ variable "resource_requirements" {
description = "The type and amount of a resource to assign to a container. The only supported resource is a GPU."
default = null
}

variable "restart_policy" {
type = object({
enabled = optional(bool)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this variable be valid if something is supplied, but enabled is left out? Maybe this should be the one required argument to this var?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm not sure - I just went off what the AWS Console generated haha
I can make this one non-optional if that is preferred?

ignoredExitCodes = optional(list(number))
restartAttemptPeriod = optional(number)
})
description = "Container restart policy. Used to restart (rather than reprovision) a container when it exits unexpectedly"
default = null
}