Skip to content

Commit 8b43d51

Browse files
committed
Update variables
1 parent ea5df8e commit 8b43d51

File tree

3 files changed

+284
-199
lines changed

3 files changed

+284
-199
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,21 +89,28 @@ In order to run all checks at any point run the following command:
8989
| <a name="input_hostname"></a> [hostname](#input\_hostname) | The hostname to use for your container. | `string` | `null` | no |
9090
| <a name="input_iam_partition"></a> [iam\_partition](#input\_iam\_partition) | IAM partition to use when referencing standard policies. GovCloud and some other regions use different partitions | `string` | `"aws"` | no |
9191
| <a name="input_interactive"></a> [interactive](#input\_interactive) | When this parameter is true, this allows you to deploy containerized applications that require stdin or a tty to be allocated. | `bool` | `null` | no |
92+
| <a name="input_ipc_mode"></a> [ipc\_mode](#input\_ipc\_mode) | (Optional) IPC resource namespace to be used for the containers in the task The valid values are host, task, and none. | `string` | `null` | no |
9293
| <a name="input_links"></a> [links](#input\_links) | List of container names this container can communicate with without port mappings | `list(string)` | `[]` | no |
9394
| <a name="input_linux_parameters"></a> [linux\_parameters](#input\_linux\_parameters) | Linux-specific modifications that are applied to the container, such as Linux kernel capabilities. For more details, see https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_LinuxParameters.html | <pre>object({<br> capabilities = object({<br> add = list(string)<br> drop = list(string)<br> })<br> devices = list(object({<br> containerPath = string<br> hostPath = string<br> permissions = list(string)<br> }))<br> initProcessEnabled = bool<br> maxSwap = number<br> sharedMemorySize = number<br> swappiness = number<br> tmpfs = list(object({<br> containerPath = string<br> mountOptions = list(string)<br> size = number<br> }))<br> })</pre> | `null` | no |
9495
| <a name="input_log_configuration"></a> [log\_configuration](#input\_log\_configuration) | Log configuration options to send to a custom log driver for the container. For more details, see https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_LogConfiguration.html | `any` | `null` | no |
9596
| <a name="input_map_environment"></a> [map\_environment](#input\_map\_environment) | The environment variables to pass to the container. This is a map of string: {key: value}. map\_environment overrides environment | `map(string)` | `null` | no |
97+
| <a name="input_map_secrets"></a> [map\_secrets](#input\_map\_secrets) | The secrets variables to pass to the container. This is a map of string: {key: value}. map\_secrets overrides secrets | `map(string)` | `null` | no |
9698
| <a name="input_mount_points"></a> [mount\_points](#input\_mount\_points) | Container mount points. This is a list of maps, where each map should contain a `containerPath` and `sourceVolume`. The `readOnly` key is optional. | `list(any)` | `[]` | no |
9799
| <a name="input_name_prefix"></a> [name\_prefix](#input\_name\_prefix) | Name prefix for resources on AWS | `any` | n/a | yes |
98100
| <a name="input_permissions_boundary"></a> [permissions\_boundary](#input\_permissions\_boundary) | (Optional) The ARN of the policy that is used to set the permissions boundary for the `ecs_task_execution_role` role. | `string` | `null` | no |
99-
| <a name="input_placement_constraints"></a> [placement\_constraints](#input\_placement\_constraints) | (Optional) A set of placement constraints rules that are taken into consideration during task placement. Maximum number of placement\_constraints is 10. This is a list of maps, where each map should contain "type" and "expression" | `list(any)` | `[]` | no |
101+
| <a name="input_pid_mode"></a> [pid\_mode](#input\_pid\_mode) | (Optional) Process namespace to use for the containers in the task. The valid values are host and task | `string` | `null` | no |
102+
| <a name="input_placement_constraints"></a> [placement\_constraints](#input\_placement\_constraints) | (Optional) A set of placement constraints rules that are taken into consideration during task placement. Maximum number of placement\_constraints is 10. | <pre>list(object({<br> expression = string # Cluster Query Language expression to apply to the constraint. For more information, see Cluster Query Language in the Amazon EC2 Container Service Developer Guide.<br> type = string # Type of constraint. Use memberOf to restrict selection to a group of valid candidates. Note that distinctInstance is not supported in task definitions.<br> }))</pre> | `[]` | no |
100103
| <a name="input_port_mappings"></a> [port\_mappings](#input\_port\_mappings) | The port mappings to configure for the container. This is a list of maps. Each map should contain "containerPort", "hostPort", and "protocol", where "protocol" is one of "tcp" or "udp". If using containers in a task with the awsvpc or host network mode, the hostPort can either be left blank or set to the same value as the containerPort | <pre>list(object({<br> containerPort = number<br> hostPort = number<br> protocol = string<br> }))</pre> | <pre>[<br> {<br> "containerPort": 80,<br> "hostPort": 80,<br> "protocol": "tcp"<br> }<br>]</pre> | no |
101104
| <a name="input_privileged"></a> [privileged](#input\_privileged) | When this variable is `true`, the container is given elevated privileges on the host container instance (similar to the root user). This parameter is not supported for Windows containers or tasks using the Fargate launch type. | `bool` | `null` | no |
102-
| <a name="input_proxy_configuration"></a> [proxy\_configuration](#input\_proxy\_configuration) | (Optional) The proxy configuration details for the App Mesh proxy. This is a list of maps, where each map should contain "container\_name", "properties" and "type" | `list(any)` | `[]` | no |
105+
| <a name="input_proxy_configuration"></a> [proxy\_configuration](#input\_proxy\_configuration) | (Optional) The proxy configuration details for the App Mesh proxy. This is a list of maps, where each map should contain "container\_name", "properties" and "type" | <pre>list(object({<br> container_name = string # Name of the container that will serve as the App Mesh proxy.<br> properties = list(object({ # Set of network configuration parameters to provide the Container Network Interface (CNI) plugin, specified a key-value mapping.<br> name = string<br> value = string<br> }))<br> type = string # Proxy type. The default value is APPMESH. The only supported value is APPMESH.<br> }))</pre> | `[]` | no |
103106
| <a name="input_pseudo_terminal"></a> [pseudo\_terminal](#input\_pseudo\_terminal) | When this parameter is true, a TTY is allocated. | `bool` | `null` | no |
104107
| <a name="input_readonly_root_filesystem"></a> [readonly\_root\_filesystem](#input\_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 |
105108
| <a name="input_repository_credentials"></a> [repository\_credentials](#input\_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 |
109+
| <a name="input_resource_requirements"></a> [resource\_requirements](#input\_resource\_requirements) | The type and amount of a resource to assign to a container. The only supported resource is a GPU. | <pre>list(object({<br> type = string<br> value = string<br> }))</pre> | `null` | no |
110+
| <a name="input_runtime_platform_cpu_architecture"></a> [runtime\_platform\_cpu\_architecture](#input\_runtime\_platform\_cpu\_architecture) | Must be set to either X86\_64 or ARM64 | `string` | `"X86_64"` | no |
111+
| <a name="input_runtime_platform_operating_system_family"></a> [runtime\_platform\_operating\_system\_family](#input\_runtime\_platform\_operating\_system\_family) | If the requires\_compatibilities is FARGATE this field is required. The valid values for Amazon ECS tasks that are hosted on Fargate are LINUX, WINDOWS\_SERVER\_2019\_FULL, WINDOWS\_SERVER\_2019\_CORE, WINDOWS\_SERVER\_2022\_FULL, and WINDOWS\_SERVER\_2022\_CORE. | `string` | `"LINUX"` | no |
106112
| <a name="input_secrets"></a> [secrets](#input\_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> | `[]` | no |
113+
| <a name="input_skip_destroy"></a> [skip\_destroy](#input\_skip\_destroy) | (Optional) Whether to retain the old revision when the resource is destroyed or replacement is necessary. Default is false. | `bool` | `false` | no |
107114
| <a name="input_start_timeout"></a> [start\_timeout](#input\_start\_timeout) | Time duration (in seconds) to wait before giving up on resolving dependencies for a container | `number` | `null` | no |
108115
| <a name="input_stop_timeout"></a> [stop\_timeout](#input\_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 |
109116
| <a name="input_system_controls"></a> [system\_controls](#input\_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))` | `[]` | no |

main.tf

Lines changed: 51 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -35,65 +35,76 @@ module "container_definition" {
3535
source = "cloudposse/ecs-container-definition/aws"
3636
version = "0.58.1"
3737

38-
container_name = var.container_name
38+
command = var.command
39+
container_cpu = var.container_cpu
40+
container_definition = var.container_definition
41+
container_depends_on = var.container_depends_on
3942
container_image = var.container_image
4043
container_memory = var.container_memory
4144
container_memory_reservation = var.container_memory_reservation
42-
container_definition = var.container_definition
43-
port_mappings = var.port_mappings
44-
healthcheck = var.healthcheck
45-
container_cpu = var.container_cpu
46-
essential = var.essential
45+
container_name = var.container_name
46+
disable_networking = var.disable_networking
47+
dns_search_domains = var.dns_search_domains
48+
dns_servers = var.dns_servers
49+
docker_labels = var.docker_labels
50+
docker_security_options = var.docker_security_options
4751
entrypoint = var.entrypoint
48-
command = var.command
49-
working_directory = var.working_directory
5052
environment = var.environment
51-
extra_hosts = var.extra_hosts
52-
map_environment = var.map_environment
5353
environment_files = var.environment_files
54-
secrets = var.secrets
55-
readonly_root_filesystem = var.readonly_root_filesystem
54+
essential = var.essential
55+
extra_hosts = var.extra_hosts
56+
firelens_configuration = var.firelens_configuration
57+
healthcheck = var.healthcheck
58+
hostname = var.hostname
59+
interactive = var.interactive
60+
links = var.links
5661
linux_parameters = var.linux_parameters
5762
log_configuration = var.log_configuration
58-
firelens_configuration = var.firelens_configuration
63+
map_environment = var.map_environment
64+
map_secrets = var.map_secrets
5965
mount_points = var.mount_points
60-
dns_servers = var.dns_servers
61-
dns_search_domains = var.dns_search_domains
62-
ulimits = var.ulimits
66+
port_mappings = var.port_mappings
67+
privileged = var.privileged
68+
pseudo_terminal = var.pseudo_terminal
69+
readonly_root_filesystem = var.readonly_root_filesystem
6370
repository_credentials = var.repository_credentials
64-
volumes_from = var.volumes_from
65-
links = var.links
66-
user = var.user
67-
container_depends_on = var.container_depends_on
68-
docker_labels = var.docker_labels
71+
resource_requirements = var.resource_requirements
72+
secrets = var.secrets
6973
start_timeout = var.start_timeout
7074
stop_timeout = var.stop_timeout
71-
privileged = var.privileged
7275
system_controls = var.system_controls
73-
hostname = var.hostname
74-
disable_networking = var.disable_networking
75-
interactive = var.interactive
76-
pseudo_terminal = var.pseudo_terminal
77-
docker_security_options = var.docker_security_options
76+
ulimits = var.ulimits
77+
user = var.user
78+
volumes_from = var.volumes_from
79+
working_directory = var.working_directory
7880
}
7981

8082
# Task Definition
8183
resource "aws_ecs_task_definition" "td" {
82-
family = "${var.name_prefix}-td"
8384
container_definitions = length(var.containers) == 0 ? "[${module.container_definition.json_map_encoded}]" : jsonencode(var.containers)
84-
task_role_arn = var.task_role_arn == null ? aws_iam_role.ecs_task_execution_role.arn : var.task_role_arn
85-
execution_role_arn = aws_iam_role.ecs_task_execution_role.arn
86-
network_mode = "awsvpc"
85+
family = var.name_prefix
86+
87+
cpu = var.container_cpu
88+
execution_role_arn = aws_iam_role.ecs_task_execution_role.arn
89+
ipc_mode = var.ipc_mode
90+
memory = var.container_memory
91+
network_mode = "awsvpc" # awsvpc required for Fargate tasks
92+
93+
runtime_platform {
94+
cpu_architecture = var.runtime_platform_cpu_architecture
95+
operating_system_family = var.runtime_platform_operating_system_family
96+
}
97+
98+
pid_mode = var.pid_mode
99+
87100
dynamic "placement_constraints" {
88101
for_each = var.placement_constraints
89102
content {
90103
expression = lookup(placement_constraints.value, "expression", null)
91104
type = placement_constraints.value.type
92105
}
93106
}
94-
cpu = var.container_cpu
95-
memory = var.container_memory
96-
requires_compatibilities = ["FARGATE"]
107+
97108
dynamic "proxy_configuration" {
98109
for_each = var.proxy_configuration
99110
content {
@@ -102,12 +113,18 @@ resource "aws_ecs_task_definition" "td" {
102113
type = lookup(proxy_configuration.value, "type", null)
103114
}
104115
}
116+
105117
dynamic "ephemeral_storage" {
106118
for_each = var.ephemeral_storage_size == 0 ? [] : [var.ephemeral_storage_size]
107119
content {
108120
size_in_gib = var.ephemeral_storage_size
109121
}
110122
}
123+
124+
requires_compatibilities = ["FARGATE"]
125+
skip_destroy = var.skip_destroy
126+
task_role_arn = var.task_role_arn == null ? aws_iam_role.ecs_task_execution_role.arn : var.task_role_arn
127+
111128
dynamic "volume" {
112129
for_each = var.volumes
113130
content {

0 commit comments

Comments
 (0)