Skip to content

Commit

Permalink
Reduce diff spam and unset defaults (#65)
Browse files Browse the repository at this point in the history
* Reduce diff spam and unset defaults

Co-authored-by: dekimsey <dekimsey@gmail.com>
Co-authored-by: Matt Gowie <gowie.matt@gmail.com>
Co-authored-by: actions-bot <58130806+actions-bot@users.noreply.github.com>
Co-authored-by: nitro <nitrocode@users.noreply.github.com>
  • Loading branch information
4 people authored Jun 16, 2020
1 parent af45dda commit 4f5e998
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ No provider.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| command | The command that is passed to the container | `list(string)` | `null` | no |
| container\_cpu | The number of cpu units to reserve for the container. This is optional for tasks using Fargate launch type and the total amount of container\_cpu of all containers in a task will need to be lower than the task-level cpu value | `number` | `256` | no |
| container\_cpu | The number of cpu units to reserve for the container. This is optional for tasks using Fargate launch type and the total amount of container\_cpu of all containers in a task will need to be lower than the task-level cpu value | `number` | `0` | no |
| container\_depends\_on | The dependencies defined for container startup and shutdown. A container can contain multiple dependencies. When a dependency is defined for container startup, for container shutdown it is reversed. The condition can be one of START, COMPLETE, SUCCESS or HEALTHY | <pre>list(object({<br> containerName = string<br> condition = string<br> }))</pre> | `null` | no |
| container\_image | The image used to start the container. Images in the Docker Hub registry available by default | `string` | n/a | yes |
| container\_memory | The amount of memory (in MiB) to allow the container to use. This is a hard limit, if the container attempts to exceed the container\_memory, the container is killed. This field is optional for Fargate launch type and the total amount of container\_memory of all containers in a task will need to be lower than the task memory value | `number` | `256` | no |
| container\_memory\_reservation | The amount of memory (in MiB) to reserve for the container. If container needs to exceed this threshold, it can do so up to the set container\_memory hard limit | `number` | `128` | no |
| container\_memory | The amount of memory (in MiB) to allow the container to use. This is a hard limit, if the container attempts to exceed the container\_memory, the container is killed. This field is optional for Fargate launch type and the total amount of container\_memory of all containers in a task will need to be lower than the task memory value | `number` | `null` | no |
| container\_memory\_reservation | The amount of memory (in MiB) to reserve for the container. If container needs to exceed this threshold, it can do so up to the set container\_memory hard limit | `number` | `null` | no |
| container\_name | The name of the container. Up to 255 characters ([a-z], [A-Z], [0-9], -, \_ allowed) | `string` | n/a | yes |
| dns\_servers | Container DNS servers. This is a list of strings specifying the IP addresses of the DNS servers | `list(string)` | `null` | no |
| docker\_labels | The configuration options to send to the `docker_labels` | `map(string)` | `null` | no |
Expand All @@ -154,12 +154,12 @@ No provider.
| readonly\_root\_filesystem | Determines whether a container is given read-only access to its root filesystem. Due to how Terraform type casts booleans in json it is required to double quote this value | `bool` | `false` | no |
| repository\_credentials | Container repository credentials; required when using a private repo. This map currently supports a single key; "credentialsParameter", which should be the ARN of a Secrets Manager's secret holding the credentials | `map(string)` | `null` | no |
| secrets | The secrets to pass to the container. This is a list of maps | <pre>list(object({<br> name = string<br> valueFrom = string<br> }))</pre> | `null` | no |
| start\_timeout | Time duration (in seconds) to wait before giving up on resolving dependencies for a container | `number` | `30` | no |
| stop\_timeout | Time duration (in seconds) to wait before the container is forcefully killed if it doesn't exit normally on its own | `number` | `30` | no |
| start\_timeout | Time duration (in seconds) to wait before giving up on resolving dependencies for a container | `number` | `null` | no |
| stop\_timeout | Time duration (in seconds) to wait before the container is forcefully killed if it doesn't exit normally on its own | `number` | `null` | no |
| system\_controls | A list of namespaced kernel parameters to set in the container, mapping to the --sysctl option to docker run. This is a list of maps: { namespace = "", value = ""} | `list(map(string))` | `null` | no |
| ulimits | Container ulimit settings. This is a list of maps, where each map should contain "name", "hardLimit" and "softLimit" | <pre>list(object({<br> name = string<br> hardLimit = number<br> softLimit = number<br> }))</pre> | `null` | no |
| user | The user to run as inside the container. Can be any of these formats: user, user:group, uid, uid:gid, user:gid, uid:group | `string` | `null` | no |
| volumes\_from | A list of VolumesFrom maps which contain "sourceContainer" (name of the container that has the volumes to mount) and "readOnly" (whether the container can write to the volume) | <pre>list(object({<br> sourceContainer = string<br> readOnly = bool<br> }))</pre> | `null` | no |
| volumes\_from | A list of VolumesFrom maps which contain "sourceContainer" (name of the container that has the volumes to mount) and "readOnly" (whether the container can write to the volume) | <pre>list(object({<br> sourceContainer = string<br> readOnly = bool<br> }))</pre> | `[]` | no |
| working\_directory | The working directory to run commands inside the container | `string` | `null` | no |

## Outputs
Expand Down
12 changes: 6 additions & 6 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ No provider.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| command | The command that is passed to the container | `list(string)` | `null` | no |
| container\_cpu | The number of cpu units to reserve for the container. This is optional for tasks using Fargate launch type and the total amount of container\_cpu of all containers in a task will need to be lower than the task-level cpu value | `number` | `256` | no |
| container\_cpu | The number of cpu units to reserve for the container. This is optional for tasks using Fargate launch type and the total amount of container\_cpu of all containers in a task will need to be lower than the task-level cpu value | `number` | `0` | no |
| container\_depends\_on | The dependencies defined for container startup and shutdown. A container can contain multiple dependencies. When a dependency is defined for container startup, for container shutdown it is reversed. The condition can be one of START, COMPLETE, SUCCESS or HEALTHY | <pre>list(object({<br> containerName = string<br> condition = string<br> }))</pre> | `null` | no |
| container\_image | The image used to start the container. Images in the Docker Hub registry available by default | `string` | n/a | yes |
| container\_memory | The amount of memory (in MiB) to allow the container to use. This is a hard limit, if the container attempts to exceed the container\_memory, the container is killed. This field is optional for Fargate launch type and the total amount of container\_memory of all containers in a task will need to be lower than the task memory value | `number` | `256` | no |
| container\_memory\_reservation | The amount of memory (in MiB) to reserve for the container. If container needs to exceed this threshold, it can do so up to the set container\_memory hard limit | `number` | `128` | no |
| container\_memory | The amount of memory (in MiB) to allow the container to use. This is a hard limit, if the container attempts to exceed the container\_memory, the container is killed. This field is optional for Fargate launch type and the total amount of container\_memory of all containers in a task will need to be lower than the task memory value | `number` | `null` | no |
| container\_memory\_reservation | The amount of memory (in MiB) to reserve for the container. If container needs to exceed this threshold, it can do so up to the set container\_memory hard limit | `number` | `null` | no |
| container\_name | The name of the container. Up to 255 characters ([a-z], [A-Z], [0-9], -, \_ allowed) | `string` | n/a | yes |
| dns\_servers | Container DNS servers. This is a list of strings specifying the IP addresses of the DNS servers | `list(string)` | `null` | no |
| docker\_labels | The configuration options to send to the `docker_labels` | `map(string)` | `null` | no |
Expand All @@ -38,12 +38,12 @@ No provider.
| readonly\_root\_filesystem | Determines whether a container is given read-only access to its root filesystem. Due to how Terraform type casts booleans in json it is required to double quote this value | `bool` | `false` | no |
| repository\_credentials | Container repository credentials; required when using a private repo. This map currently supports a single key; "credentialsParameter", which should be the ARN of a Secrets Manager's secret holding the credentials | `map(string)` | `null` | no |
| secrets | The secrets to pass to the container. This is a list of maps | <pre>list(object({<br> name = string<br> valueFrom = string<br> }))</pre> | `null` | no |
| start\_timeout | Time duration (in seconds) to wait before giving up on resolving dependencies for a container | `number` | `30` | no |
| stop\_timeout | Time duration (in seconds) to wait before the container is forcefully killed if it doesn't exit normally on its own | `number` | `30` | no |
| start\_timeout | Time duration (in seconds) to wait before giving up on resolving dependencies for a container | `number` | `null` | no |
| stop\_timeout | Time duration (in seconds) to wait before the container is forcefully killed if it doesn't exit normally on its own | `number` | `null` | no |
| system\_controls | A list of namespaced kernel parameters to set in the container, mapping to the --sysctl option to docker run. This is a list of maps: { namespace = "", value = ""} | `list(map(string))` | `null` | no |
| ulimits | Container ulimit settings. This is a list of maps, where each map should contain "name", "hardLimit" and "softLimit" | <pre>list(object({<br> name = string<br> hardLimit = number<br> softLimit = number<br> }))</pre> | `null` | no |
| user | The user to run as inside the container. Can be any of these formats: user, user:group, uid, uid:gid, user:gid, uid:group | `string` | `null` | no |
| volumes\_from | A list of VolumesFrom maps which contain "sourceContainer" (name of the container that has the volumes to mount) and "readOnly" (whether the container can write to the volume) | <pre>list(object({<br> sourceContainer = string<br> readOnly = bool<br> }))</pre> | `null` | no |
| volumes\_from | A list of VolumesFrom maps which contain "sourceContainer" (name of the container that has the volumes to mount) and "readOnly" (whether the container can write to the volume) | <pre>list(object({<br> sourceContainer = string<br> readOnly = bool<br> }))</pre> | `[]` | no |
| working\_directory | The working directory to run commands inside the container | `string` | `null` | no |

## Outputs
Expand Down
8 changes: 6 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ locals {
systemControls = var.system_controls
extraHosts = var.extra_hosts
}

json_map = jsonencode(local.container_definition)
container_definition_without_null = {
for k, v in local.container_definition :
k => v
if v != null
}
json_map = jsonencode(local.container_definition_without_null)
}
12 changes: 6 additions & 6 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ variable "container_image" {
variable "container_memory" {
type = number
description = "The amount of memory (in MiB) to allow the container to use. This is a hard limit, if the container attempts to exceed the container_memory, the container is killed. This field is optional for Fargate launch type and the total amount of container_memory of all containers in a task will need to be lower than the task memory value"
default = 256
default = null
}

variable "container_memory_reservation" {
type = number
description = "The amount of memory (in MiB) to reserve for the container. If container needs to exceed this threshold, it can do so up to the set container_memory hard limit"
default = 128
default = null
}

variable "port_mappings" {
Expand Down Expand Up @@ -48,7 +48,7 @@ variable "healthcheck" {
variable "container_cpu" {
type = number
description = "The number of cpu units to reserve for the container. This is optional for tasks using Fargate launch type and the total amount of container_cpu of all containers in a task will need to be lower than the task-level cpu value"
default = 256
default = 0
}

variable "essential" {
Expand Down Expand Up @@ -207,7 +207,7 @@ variable "volumes_from" {
readOnly = bool
}))
description = "A list of VolumesFrom maps which contain \"sourceContainer\" (name of the container that has the volumes to mount) and \"readOnly\" (whether the container can write to the volume)"
default = null
default = []
}

variable "links" {
Expand Down Expand Up @@ -240,13 +240,13 @@ variable "docker_labels" {
variable "start_timeout" {
type = number
description = "Time duration (in seconds) to wait before giving up on resolving dependencies for a container"
default = 30
default = null
}

variable "stop_timeout" {
type = number
description = "Time duration (in seconds) to wait before the container is forcefully killed if it doesn't exit normally on its own"
default = 30
default = null
}

variable "privileged" {
Expand Down

0 comments on commit 4f5e998

Please sign in to comment.