aws Batch Jobdefinition Cloudfromation错误

时间:2018-04-04 03:30:12

标签: amazon-web-services amazon-cloudformation

我收到以下错误 属性验证失败:[{ContainerProperties}中遇到不受支持的属性:[environment,user,command]]

{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Description": "AWS Batch Refarch - Unmanaged ECS cluster",
    "Parameters": {
        "JobDefinitionName": {
            "Description": "Job Definition",
            "Type": "String"
        },
        "ContainerBootstrapCommand1": {
            "Description": "Enter the Job Name",
            "Type": "String",
            "Default": "myjob.sh"
        },
        "ContainerBootstrapCommand1Timeout": {
            "Description": "Choose a subnet to which this ECS cluster should be deployed",
            "Type": "String",
            "Default": "60"
        },
        "ImageContainer": {
            "Description": "Enter the ARN Name for the container image",
            "Type": "String",
            "Default": "848282188376513.dkr.ecr.us-east-1.amazonaws.com/awsbatch/fetch_and_run"
        },
        "JobRole": {
            "Description": "Enter the ARN Name for the container image",
            "Type": "String",
            "Default": "arn:aws:iam::848282188376513:role/batchJobRole"
        }
    },
    "Resources": {
        "JobDefinition": {
            "Type": "AWS::Batch::JobDefinition",
            "Properties": {
                "Type": "container",
                "JobDefinitionName": {
                    "Ref": "JobDefinitionName"
                },
                "ContainerProperties": {
                    "Image": {
                        "Ref": "ImageContainer"
                    },
                    "Vcpus": 4,
                    "Memory": 2000,
                    "command": [
                        {
                            "Ref": "ContainerBootstrapCommand1"
                        },
                        {
                            "Ref": "ContainerBootstrapCommand1"
                        }
                    ],
                    "JobRoleArn": {
                        "Ref": "JobRole"
                    },
                    "environment": [
                        {
                            "name": "BATCH_FILE_S3_URL",
                            "value": "s3://mybucket/myjob.sh"
                        },
                        {
                            "name": "BATCH_FILE_TYPE",
                            "value": "script"
                        }
                    ],
                    "ReadonlyRootFilesystem": true,
                    "Privileged": true,
                    "user": "nobody"
                }
            }
        }
    }
}

1 个答案:

答案 0 :(得分:1)

你的teamplate中只有小错字。

属性需要调用Command而不是commandEnvironment而不是environmentUser而不是user

查看documentation了解详情

(如果您仔细阅读了错误消息,那么您将自己解决此问题)