Skip to content

feat: Remove empty containers (map/list) from container definition #336

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

Merged
merged 1 commit into from
Aug 7, 2025

Conversation

bryantbiggs
Copy link
Member

Description

  • Remove empty containers (map/list) from container definition

Motivation and Context

relates to hashicorp/terraform-provider-aws#17988

Breaking Changes

  • No

How Has This Been Tested?

  • I have updated at least one of the examples/* to demonstrate and validate my change(s)
  • I have tested and validated these changes using one or more of the provided examples/* projects
  • I have executed pre-commit run -a on my pull request

Deploying the complete example from master and then changing to this PR produces the following desired diff
image

@@ -311,13 +307,14 @@ variable "resourceRequirements" {
variable "restartPolicy" {
description = "Container restart policy; helps overcome transient failures faster and maintain task availability"
type = object({
enabled = optional(bool)
enabled = optional(bool, true)
Copy link
Member Author

Choose a reason for hiding this comment

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

name = var.name
portMappings = var.portMappings != null ? [for p in var.portMappings : { for k, v in p : k => v if v != null }] : null
privileged = local.is_not_windows ? var.privileged : null
pseudoTerminal = var.pseudoTerminal
readonlyRootFilesystem = local.is_not_windows ? var.readonlyRootFilesystem : null
repositoryCredentials = var.repositoryCredentials
resourceRequirements = var.resourceRequirements
restartPolicy = { for k, v in var.restartPolicy : k => v if v != null }
restartPolicy = local.trimmedRestartPolicy.enabled ? local.trimmedRestartPolicy : null
Copy link
Member Author

Choose a reason for hiding this comment

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

if enabled = false then we don't send any configs for restartPolicy to the Task Definition API call

Copy link
Member

@antonbabenko antonbabenko left a comment

Choose a reason for hiding this comment

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

If it works, LGTM :)

@bryantbiggs bryantbiggs merged commit 24746cc into master Aug 7, 2025
12 checks passed
antonbabenko pushed a commit that referenced this pull request Aug 7, 2025
## [6.2.0](v6.1.4...v6.2.0) (2025-08-07)

### Features

* Remove empty containers (map/list) from container definition ([#336](#336)) ([24746cc](24746cc))
@bryantbiggs bryantbiggs deleted the chore/more-container-def branch August 7, 2025 14:55
@antonbabenko
Copy link
Member

This PR is included in version 6.2.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ECS Fargate with Windows Containers does not support Restart Policy
2 participants