3

我正在尝试将由 S3 PutObject 上的 Cloudwatch 事件触发的 AWS Batch 作业设置到存储桶中。添加新文件时,我的作业正在运行,但不确定如何将文件名传递给作业。在我的 Cloudwatch 事件规则中,我将批处理作业队列设置Configure inputMatched event,但不确定如何访问作业正在运行的 docker 容器中的事件。

4

1 回答 1

0

As described here: https://docs.aws.amazon.com/batch/latest/userguide/batch-cwe-target.html, towards the bottom, in the section titled "Passing Event Information to an AWS Batch Target using the CloudWatch Events Input Transformer":

Set your job definition up like so:

{
  "jobDefinitionName": "echo-parameters",
  "containerProperties": {
    "image": "busybox",
    "vcpus": 2,
    "memory": 2000,
    "command": [
      "echo",
      "Ref::S3bucket",
      "Ref::S3key"
    ]
  }
}

This assumes your docker image contains a command echo which takes 2 parameters - an S3 bucket and an S3 key.

In your CloudWatch Event rule, use an InputTransformer to transform the event details into what you want:

"InputTransformer": {
  "InputPathsMap" : {
    "S3BucketValue": "$.detail.requestParameters.bucketName",
    "S3KeyValue": "$.detail.requestParameters.key"
  },
  "InputTemplate" : "{\"S3bucket\": <S3BucketValue>, \"S3key\": <S3KeyValue>}"
}
于 2018-07-12T07:05:56.700 回答