gpt4 book ai didi

amazon-web-services - 如何在 AWS cloudformation 模板中将 Batch 作业队列配置为 AWS::Events::Rule 的目标

转载 作者:行者123 更新时间:2023-12-05 04:04:19 24 4
gpt4 key购买 nike

我的 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 event target

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

最佳答案

嘿,我试图自己寻找样本,但没有找到。经过一些测试我明白了。我想我应该在这里分享。

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}

关于amazon-web-services - 如何在 AWS cloudformation 模板中将 Batch 作业队列配置为 AWS::Events::Rule 的目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52728830/

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