Search code examples
amazon-web-servicesaws-cloudformationamazon-ecs

AWS Cloudformation creates task definition with no container definition


The following CloudFormation script creates a task definition but does not seem to create the container definition correctly. Can anyone tell me why?

{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Test stack for troubleshooting task creation",
"Parameters": {
    "TaskFamily": {
        "Description": "The task family to associate the task definition with.",
        "Type": "String",
        "Default": "Dm-Testing"
    }
},
"Resources": {
    "TaskDefinition": {
        "Type": "AWS::ECS::TaskDefinition",
        "Properties": {
            "Family": {
                "Ref": "TaskFamily"
            },
            "RequiresCompatibilities": [
                "EC2"
            ],
            "ContainerDefinitions": [
                {
                    "Name": "sample-app",
                    "Image": "nginx",
                    "Memory": 200,
                    "Cpu": 10,
                    "Essential": true,
                    "Environment": [
                        {
                            "Name": "SOME_ENV_VARIABLE",
                            "Value": "SOME_VALUE"
                        }
                    ]
                }
            ]
        }
    }
}
}

When I view the created task, there is no container listed in the builder view of task definition in aws.

Task Definition

The information is listed, however, under the json tab of the task definition:

Json View Of container definitions

Note that the above image is a subset of the info shown, not all of it.

The result of this is that, when the task is run in a cluster, it does run the image, but runs it without the environment variables applied. In addition, CF does not report any errors when creating this stack, or when running the created task.

Finally, the CloudFormation script is a cut down example of the 'real' script which has started exhibiting this same issue. That script has been working fine for around a year now, and, as far as I can see, there have been no changes to the script between it working and breaking.

I would greatly appreciate any thoughts or suggestions on this because my face is beginning to hurt from smashing it against this particular wall.


Solution

  • Turns out this was a bug in cloudformation that only occurred when creating a task definition using a script through the aws console. Amazon have now resolved this.