Trying to configure ECS taskdefinition with ephemeralStorage

Hi

I am successfully configuring an ECS Task Definition with community.aws.ecs_taskdefinition.
Now one of the containers needs to have a bigger volume. According to Fargate task ephemeral storage for Amazon ECS - Amazon Elastic Container Service, this can be done by adding an ephemeralStorage parameter.

But this does not seem to be possible using community.aws.ecs_taskdefinition - or I don’t know how to do that.

Clearly it’s not supported as a top level parameter for the task:

fatal: [localhost]: FAILED! => changed=false 
  msg: 'Unsupported parameters for (community.aws.ecs_taskdefinition) module: ephemeralStorage. Supported parameters include: access_key, arn, aws_ca_bundle, aws_config, containers, cpu, debug_botocore_endpoint_logs, endpoint_url, execution_role_arn, family, force_create, launch_type, memory, network_mode, placement_constraints, profile, region, revision, runtime_platform, secret_key, session_token, state, task_role_arn, validate_certs, volumes (access_token, aws_access_key, aws_access_key_id, aws_endpoint_url, aws_profile, aws_region, aws_secret_access_key, aws_secret_key, aws_security_token, aws_session_token, ec2_access_key, ec2_region, ec2_secret_key, ec2_url, s3_url, security_token).'

and neither as a parameter for the entries in the containers list parameter:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: Unknown parameter in containerDefinitions[1]: "ephemeralStorage", must be one of: name, image, repositoryCredentials, cpu, memory, memoryReservation, links, portMappings, essential, entryPoint, command, environment, environmentFiles, mountPoints, volumesFrom, linuxParameters, secrets, dependsOn, startTimeout, stopTimeout, hostname, user, workingDirectory, disableNetworking, privileged, readonlyRootFilesystem, dnsServers, dnsSearchDomains, extraHosts, dockerSecurityOptions, interactive, pseudoTerminal, dockerLabels, ulimits, logConfiguration, healthCheck, systemControls, resourceRequirements, firelensConfiguration, credentialSpecs
fatal: [localhost]: FAILED! => changed=false 
  boto3_version: 1.34.64
  botocore_version: 1.34.64
  msg: |-
    Failed to register task: Parameter validation failed:
    Unknown parameter in containerDefinitions[1]: "ephemeralStorage", must be one of: name, image, repositoryCredentials, cpu, memory, memoryReservation, links, portMappings, essential, entryPoint, command, environment, environmentFiles, mountPoints, volumesFrom, linuxParameters, secrets, dependsOn, startTimeout, stopTimeout, hostname, user, workingDirectory, disableNetworking, privileged, readonlyRootFilesystem, dnsServers, dnsSearchDomains, extraHosts, dockerSecurityOptions, interactive, pseudoTerminal, dockerLabels, ulimits, logConfiguration, healthCheck, systemControls, resourceRequirements, firelensConfiguration, credentialSpecs

Any ideas on how to get this work?

I guess I can just build the JSON structure for the task definition myself and feed that into aws ecs register-task-definition but I’d rather not do that unless absolutely necessary…

I did some more checking and I’m fairly sure what I want is not supported by community.aws.ecs_taskdefinition.
So, I now have added this extra task after community.aws.ecs_taskdefinition that will fetch the task definition, add the required configuration, and then create a new task definition with that. Not ideal, but it does seem to work:

- name: Add a custom ehphemeralStorage configuration to the task defintion
  ansible.builtin.shell:  # noqa no-changed-when
    cmd: >-
      set -o pipefail &&
      aws ecs register-task-definition --cli-input-json
      "$(aws ecs describe-task-definition --task-definition {{ ecs_task_def.taskdefinition.taskDefinitionArn | quote }} | jq -r '
        .taskDefinition
        | del(.taskDefinitionArn, .revision, .status, .requiresAttributes,.compatibilities, .registeredAt, .registeredBy)
        |. +={ ephemeralStorage: { sizeInGiB: 128 }}' )"