我一直在阅读documentation for AWS Cloudwatch events至trigger AWS Batch,但无法弄清楚如何从cloudwatch事件触发aws批处理:
在aws cli中,我可以使用以下bash代码成功执行aws批处理作业:
BATCH_JOB_QUEUE_NAME="test-batch-job-queue"
BATCH_JOB_DEFINITION_NAME="test-batch-job-def"
BATCH_JOB_DEFINITION_ARN=$( aws batch describe-job-definitions \
--job-definition-name ${BATCH_JOB_DEFINITION_NAME} \
--status ACTIVE \
| jq -r '.jobDefinitions | max_by(.revision).jobDefinitionArn' \
) && echo ${BATCH_JOB_DEFINITION_ARN}
echo "Submitting job with additional ${SIZE_OF_RAM}GB RAM\n"
aws batch submit-job \
--job-name ${BATCH_JOB_NAME} \
--job-queue `aws batch describe-job-queues --job-queues $BATCH_JOB_QUEUE_NAME | jq ".jobQueues[].jobQueueArn" -r` \
--job-definition $BATCH_JOB_DEFINITION_ARN \
--parameters configFile="s3://${BUCKET_NAME}/${PROJECT_NAME}/config.json" \ <=== *****important configuration
--container-overrides vcpus=16,memory=16000 \ . <=== *****important configuration
--profile ${PROJECT_NAME}-${environment}
但是通过AWS Cloudwatch Events,我的cloudformation yaml出现了错误
Resources:
TestBatchSchedule:
Type: AWS::Events::Rule
Properties:
Description: Test bi-monthly schedule
Name: TestBiMonthlySchedule
ScheduleExpression: cron(0 7 * * 2) # every two weeks at 7 am
State: 'ENABLED'
Targets:
- Arn: test-arn
BatchParameters:
JobDefinition:
Fn::ImportValue: !Sub "${Environment}-test-batch-def"
JobName: "test-batch-scheduled-job"
RetryStrategy:
Attempts: 1
Id: test-id
InputTransformer:
InputPathsMap:
parameters:
configFile: s3://test-batch-bucket/test-project/config.json
containerProperties:
vcpus: 16
memory: 32000
InputTemplate: "s3://test-batch-bucket/test-project/config.json"
返回此错误:
属性InputPathsMap的值必须是带有String的对象(或 简单类型)属性
我的具体问题是如何将parameters
和container overrides
部分添加到cloudformation AWS :: Events :: Rule中?我也想将其保存在yaml中。
答案 0 :(得分:0)
InputPathsMap是一个数组键值对,其中每个值都是有效的JSON路径。您最多可以有10个键值对。 您必须使用JSON点表示法,而不是括号表示法。
我没有检查,但是您可以按照以下说明尝试吗?
InputPathsMap:
parameters.configFile: s3://test-batch-bucket/test-project/config.json
parameters.containerProperties.vcpus: 16
parameters.containerProperties.memory: 32000