【发布时间】:2020-07-13 10:02:52
【问题描述】:
我有一个 terraform 项目,我正在尝试设置 cloudwatch 事件规则和目标,以按计划触发新的 aws 批处理作业提交。我遇到的问题是将静态参数(即表示要运行的命令的变量)从 cloudwatch 事件传递给 batch_target。
在我的 aws_batch_job_definition 中,我将以下内容作为 container_properties 的一部分:
container_properties = <<CONTAINER_PROPERTIES
{
"command": ["echo", "command", "Ref::inputCommand"],
...etc
}
我的 cloudwatch 事件目标绑定到调度规则如下所示:
resource "aws_cloudwatch_event_target" "test_target" {
rule = aws_cloudwatch_event_rule.every_minute.name
role_arn = aws_iam_role.event_iam_role.arn
arn = aws_batch_job_queue.test_queue.arn
batch_target {
job_definition = aws_batch_job_definition.test.arn
job_name = "job-test"
job_attempts = 2
}
input = "{\"inputCommand\": \"commandToRun\"}" #this line does not work as intended
}
是否有一种简单的方法可以使用 event_target 的 input 或 input_transformer 属性将变量 inputCommand 传递给批处理作业?
当我提交具有通过控制台设置的参数和值的作业时,设置工作正常,或者在作业定义中设置默认参数,但我无法通过 terraform 中的 cloudwatch 事件执行此操作。
【问题讨论】:
标签: amazon-web-services terraform aws-batch