gpt4 book ai didi

aws-cloudformation - AWS Cloudformation 创建 AWS Cloudwatch 事件以触发 AWS Batch

转载 作者:行者123 更新时间:2023-12-03 07:27:35 37 4
gpt4 key购买 nike

我一直在阅读documentation for AWS Cloudwatch eventstrigger 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"

返回此错误:

Value of property InputPathsMap must be an object with String (or simple type) properties

我的具体问题是如何将参数容器覆盖部分添加到cloudformation AWS::Events::Rule?我也想将其保留在 yaml 中。

最佳答案

根据https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-inputtransformer.html#cfn-events-rule-inputtransformer-inputpathsmap

InputPathsMap is an array key-value pairs, where each value is a valid JSON path. You can have as many as 10 key-value pairs. You must use JSON dot notation, not bracket notation.

我没有检查过,但你可以按照以下方式尝试一下吗?

InputPathsMap:
parameters.configFile: s3://test-batch-bucket/test-project/config.json
parameters.containerProperties.vcpus: 16
parameters.containerProperties.memory: 32000

关于aws-cloudformation - AWS Cloudformation 创建 AWS Cloudwatch 事件以触发 AWS Batch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60089140/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com