amazon-web-services - 如何在 AWS cloudformation 模板中将批处理作业队列配置为 AWS::Events::Rule 的目标
问题描述
我的 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 模板
解决方案
嘿,我试图自己找一个样品,但没有找到。通过一些测试,我明白了。以为我会在这里分享它。
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}
推荐阅读
- lisp - 关于 mapcon 及其假定等价的问题 (apply #'nconc (maplist ...))
- python - 删除记录后,如何在我的 simple-orm 数据库中重新编号 ID?
- travis-ci - 如何使用 jupyter 笔记本解决 travis 上的 sphinx 错误?
- python - 如何使用python使用正则表达式
- android - 我无法将 EditText 数据存储在 val 名称中
- firefox - 为什么我没有字符串存在错误:null-title
- java - 如何使用 Flutter 和 Java Spring 创建独立的桌面应用程序,而无需在 localhost 上创建 Web 服务器
- javascript - RTK 查询“merge-patch+json”内容类型破坏请求体
- r - 加快正则表达式替换
- vue.js - Vue中Axios GET请求404错误如何解决?