简体   繁体   English

AWS Cloudformation创建没有容器定义的任务定义

[英]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. 以下CloudFormation脚本创建任务定义,但似乎没有正确创建容器定义。 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. 当我查看创建的任务时,aws中的任务定义的构建器视图中没有列出容器。

任务定义

The information is listed, however, under the json tab of the task definition: 但是,列出的信息位于任务定义的json选项卡下:

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. 此外,CF在创建此堆栈或运行创建的任务时不会报告任何错误。

Finally, the CloudFormation script is a cut down example of the 'real' script which has started exhibiting this same issue. 最后,CloudFormation脚本是“真实”脚本的缩减示例,该脚本已开始展示同样的问题。 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. 事实证明这是一个只在通过aws控制台使用脚本创建任务定义时才会出现的云形态错误。 Amazon have now resolved this. 亚马逊现在解决了这个问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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