2

我的 AWS cloudformation 模板有这个:

    "ScheduledRule": {
      "Type": "AWS::Events::Rule",
      "Properties": {
        "Description": "ScheduledRule",
        "ScheduleExpression": "cron(0/5 * * * ? *)",
        "State": "ENABLED",
        "Targets": [{
           "Here I want to set batch job queue"
        }]
      }
    }

我在模板中为 AWS Batch 创建了必要的实体。

    "JobDefinition": {
      "Type": "AWS::Batch::JobDefinition",
      "Properties": {
        "Type": "container",
        "ContainerProperties": {
          "Image": {
                        "Ref": "ImageUrl"
                    },
          "Vcpus": 2,
          "Memory": 2000,
          "Command": ["node", "server.js"]
        },
        "RetryStrategy": {
          "Attempts": 1
        }
      }
    },
    "JobQueue": {
      "Type": "AWS::Batch::JobQueue",
      "Properties": {
        "Priority": 1,
        "ComputeEnvironmentOrder": [
          {
            "order": 1,
            "ComputeEnvironment": { "Ref": "ComputeEnvironment" }
          }
        ]
      }
    },
    "ComputeEnvironment": {
      "Type": "AWS::Batch::ComputeEnvironment",
      "Properties": {
        "Type": "MANAGED", 
        "ComputeResourses": {
          "Type": "EC2",
          "MinvCpus": 2,
          "DesiredvCpus": 4,
          "MaxvCpus": 64,
          "InstanceTypes": [
            "optimal"
          ],
          "Subnets" : [{ "Ref" : "Subnet" }],
          "SecurityGroupIds" : [{ "Ref" : "SecurityGroup" }],
          "InstanceRole" : { "Ref" : "IamInstanceProfile" }
        },
        "ServiceRole" : { "Ref" : "BatchServiceRole" }
      }
    }

我知道可以通过 aws cloudwatch 事件提交批处理作业。AWS cloudwatch 事件目标

我想使用批处理作业队列目标通过 cloudformation 模板提交我的作业。我见过很多通过 AWS lambda 函数完成批量作业提交的示例,但我不想使用 lambda 函数。我没有找到在“AWS::Events::Rule”中配置批处理作业队列目标的任何 cloudformation 模板

4

1 回答 1

0

嘿,我试图自己找一个样品,但没有找到。通过一些测试,我明白了。以为我会在这里分享它。

Targets: - Arn: Ref: BatchProcessingJobQueue Id: {your_id} RoleArn: {your_role_arn} BatchParameters: JobDefinition: Ref: BatchProcessingJobDefinition JobName: {your_job_name} Input: !Sub - '{"Parameters": {"param1": "--param.name1=${param1}", "param2": "--param.name2=${param2}"}}' - param1: {param1_value} param2: {param2_value}

于 2020-03-25T22:32:42.053 回答