简体   繁体   中英

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.

任务定义

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

Json View Of容器定义

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM