Description
Description
RegisterTaskDefinitionAsync can not be used to register Fargate tasks due to incorrect strongly typed mappings. For the container definition Fargate accepts null entries for many of the options, including most importantly for my needs memory and memory reservation. This gets set at the task group level and is not necessary at the individual container level. As it stands if I take the definition of a task that was registered using the AWS UI, I cannot modify it using the SDK due to this limitation.
Reproduction Steps
Inspecting the request on the AWS UI at https://console.aws.amazon.com/ecs/home?region=us-east-1#/taskDefinitions I can see the following JSON. (sensitive information in curly braces ommited)
{
"ipcMode": null,
"executionRoleArn": "arn:aws:iam::{someID}:role/{someRole}",
"containerDefinitions": [{
"dnsSearchDomains": null,
"environmentFiles": null,
"logConfiguration": {
"logDriver": "awslogs",
"secretOptions": null,
"options": {
"awslogs-group": "{someLogGroup}",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "ecs"
}
},
"entryPoint": null,
"portMappings": [{
"protocol": "tcp",
"containerPort": {somePort}
}
],
"command": null,
"linuxParameters": null,
"cpu": 0,
"environment": [],
"resourceRequirements": null,
"ulimits": null,
"dnsServers": null,
"mountPoints": [],
"workingDirectory": null,
"secrets": null,
"dockerSecurityOptions": null,
"memory": null,
"memoryReservation": null,
"volumesFrom": [],
"stopTimeout": null,
"image": "{someImage}",
"startTimeout": null,
"firelensConfiguration": null,
"dependsOn": null,
"disableNetworking": null,
"interactive": null,
"healthCheck": null,
"essential": true,
"links": null,
"hostname": null,
"extraHosts": null,
"pseudoTerminal": null,
"user": null,
"readonlyRootFilesystem": null,
"dockerLabels": null,
"systemControls": null,
"privileged": null,
"name": "service"
}
],
"memory": "2048",
"taskRoleArn": "arn:aws:iam::{someID}:role/{someRole}",
"family": "internal-services-template",
"pidMode": null,
"requiresCompatibilities": ["FARGATE"],
"networkMode": "awsvpc",
"cpu": "256",
"inferenceAccelerators": [],
"proxyConfiguration": null,
"volumes": []
}
If I call DescribeTaskDefinitionAsync on this task definition all of the null values will be replaced with default int or bool values. 0 or false. If I then try to use those container definitions to call RegisterTaskDefinitionAsync it will fail due to invalid values on several of the properties.
Logs
Environment
- SDK Version: All
- Package Version: All
- OS Info: All
- Build Environment All
- Targeted .NET Platform:
Resolution
- 👋 I can/would-like-to implement a fix for this problem myself
move all bool, and int properties to their nullable equivalents bool? and int?
https://github.com/aws/aws-sdk-net/blob/master/sdk/src/Services/ECS/Generated/Model/ContainerDefinition.cs
This is a 🐛 bug-report