Skip to content

feat: Add version consistency support in container definition #280

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
3 changes: 2 additions & 1 deletion modules/container-definition/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ No modules.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_cloudwatch_log_group_kms_key_id"></a> [cloudwatch\_log\_group\_kms\_key\_id](#input\_cloudwatch\_log\_group\_kms\_key\_id) | If a KMS Key ARN is set, this key will be used to encrypt the corresponding log group. Please be sure that the KMS Key has an appropriate key policy (https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/encrypt-log-data-kms.html) | `string` | `null` | no |
| <a name="input_cloudwatch_log_group_kms_key_id"></a> [cloudwatch\_log\_group\_kms\_key\_id](#input\_cloudwatch\_log\_group\_kms\_key\_id) | If a KMS Key ARN is set, this key will be used to encrypt the corresponding log group. Please be sure that the KMS Key has an appropriate key policy (<https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/encrypt-log-data-kms.html>) | `string` | `null` | no |
| <a name="input_cloudwatch_log_group_name"></a> [cloudwatch\_log\_group\_name](#input\_cloudwatch\_log\_group\_name) | Custom name of CloudWatch log group for a service associated with the container definition | `string` | `null` | no |
| <a name="input_cloudwatch_log_group_retention_in_days"></a> [cloudwatch\_log\_group\_retention\_in\_days](#input\_cloudwatch\_log\_group\_retention\_in\_days) | Number of days to retain log events. Default is 30 days | `number` | `30` | no |
| <a name="input_cloudwatch_log_group_use_name_prefix"></a> [cloudwatch\_log\_group\_use\_name\_prefix](#input\_cloudwatch\_log\_group\_use\_name\_prefix) | Determines whether the log group name should be used as a prefix | `bool` | `false` | no |
Expand Down Expand Up @@ -186,6 +186,7 @@ No modules.
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | `{}` | no |
| <a name="input_ulimits"></a> [ulimits](#input\_ulimits) | A list of ulimits to set in the container. If a ulimit value is specified in a task definition, it overrides the default values set by Docker | <pre>list(object({<br/> hardLimit = number<br/> name = string<br/> softLimit = number<br/> }))</pre> | `[]` | no |
| <a name="input_user"></a> [user](#input\_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. The default (null) will use the container's configured `USER` directive or root if not set | `string` | `null` | no |
| <a name="input_version_consistency"></a> [version\_consistency](#input\_version\_consistency) | Specifies whether Amazon ECS will resolve the container image tag provided in the container definition to an image digest. The default is `enabled`. If set to `disabled`, Amazon ECS will not resolve the container image tag to a digest (<https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-type-ecs.html#deployment-container-image-stability>). | `string` | `"enabled"` | no |
| <a name="input_volumes_from"></a> [volumes\_from](#input\_volumes\_from) | Data volumes to mount from another container | `list(any)` | `[]` | no |
| <a name="input_working_directory"></a> [working\_directory](#input\_working\_directory) | The working directory to run commands inside the container | `string` | `null` | no |

Expand Down
1 change: 1 addition & 0 deletions modules/container-definition/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ locals {
user = local.is_not_windows ? var.user : null
volumesFrom = var.volumes_from
workingDirectory = var.working_directory
versionConsistency = var.version_consistency
}

# Strip out all null values, ECS API will provide defaults in place of null/empty values
Expand Down
9 changes: 9 additions & 0 deletions modules/container-definition/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,15 @@ variable "working_directory" {
default = null
}

variable "version_consistency" {
description = "Specifies whether Amazon ECS will resolve the container image tag provided in the container definition to an image digest. The default is `enabled`. If set to `disabled`, Amazon ECS will not resolve the container image tag to a digest (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-type-ecs.html#deployment-container-image-stability)."
type = string
validation {
condition = contains(["enabled", "disabled"], var.version_consistency)
error_message = "The version consistency must be either `enabled` or `disabled`"
}
default = "enabled"
}
################################################################################
# CloudWatch Log Group
################################################################################
Expand Down
1 change: 1 addition & 0 deletions modules/service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ module "container_definition" {
user = try(each.value.user, var.container_definition_defaults.user, 0)
volumes_from = try(each.value.volumes_from, var.container_definition_defaults.volumes_from, [])
working_directory = try(each.value.working_directory, var.container_definition_defaults.working_directory, null)
version_consistency = try(each.value.version_consistency, var.container_definition_defaults.version_consistency, "enabled")

# CloudWatch Log Group
service = var.name
Expand Down
Loading