使用Pulumi设置EventBridge Cron进行AWS批处理工作

发布于 2025-02-10 04:09:00 字数 1455 浏览 3 评论 0原文

我正在尝试设置EventBridge,以定期开始批处理工作。我可以通过PULUMI部署批处理作业和事件规则,但是当我尝试部署EventTarget时,我会得到此错误:

创建EventBridge目标失败:验证Exception:参数(S) batchparameter不支持目标:my_event_target-ca7145e。

我已经通过AWS控制台为同一批处理作业设置了一个EventBridge,没有任何问题,而且运行良好。

这是代码:

const eventBridgeDeadLetterQueue = new aws.sns.Topic("myEventBridge", {});

const myJob = new aws.batch.JobDefinition("my_job", {
    containerProperties: pulumi.interpolate `{
        "image": "${myImage}",
        "resourceRequirements": [
            {"type": "VCPU", "value": "1"},
            {"type": "MEMORY", "value": "4096"}
          ],
        "environment": [],
        "jobRoleArn": "${myEcsTaskRole.arn}",
        "executionRoleArn": "${myEcsTaskExecutionRole.arn}"
    }`,
    type: "container",
    timeout: {
        'attemptDurationSeconds': 30 * 60
    },
    platformCapabilities: ['FARGATE']
});

const myRule = new aws.cloudwatch.EventRule("myRule", {
    description: "Fire a batch job",
    scheduleExpression: "cron(30 15 * * ? *)"
});

//if I comment out this target, then I can successfully deploy
const myEventTarget = new aws.cloudwatch.EventTarget("my_event_target", {
    arn: eventBridgeDeadLetterQueue.arn,
    rule: myRule.name,
    inputPath: "$",  //I have also tried with input: "" and get the same error
    batchTarget: {
        jobDefinition: myJob.arn,
        jobName: "My Job Name"
    }
});

我在做什么错?谢谢!

I'm trying to set up EventBridge to kick off a Batch job on a regular schedule. I can deploy the batch job and the event rule through Pulumi, but when I attempt to deploy the EventTarget, I get this error:

Creating EventBridge Target failed: ValidationException: Parameter(s)
BatchParameters not supported for target: my_event_target-ca7145e.

I have set up an EventBridge for the same batch job through the AWS Console with no issue, and it runs fine.

Here is the code:

const eventBridgeDeadLetterQueue = new aws.sns.Topic("myEventBridge", {});

const myJob = new aws.batch.JobDefinition("my_job", {
    containerProperties: pulumi.interpolate `{
        "image": "${myImage}",
        "resourceRequirements": [
            {"type": "VCPU", "value": "1"},
            {"type": "MEMORY", "value": "4096"}
          ],
        "environment": [],
        "jobRoleArn": "${myEcsTaskRole.arn}",
        "executionRoleArn": "${myEcsTaskExecutionRole.arn}"
    }`,
    type: "container",
    timeout: {
        'attemptDurationSeconds': 30 * 60
    },
    platformCapabilities: ['FARGATE']
});

const myRule = new aws.cloudwatch.EventRule("myRule", {
    description: "Fire a batch job",
    scheduleExpression: "cron(30 15 * * ? *)"
});

//if I comment out this target, then I can successfully deploy
const myEventTarget = new aws.cloudwatch.EventTarget("my_event_target", {
    arn: eventBridgeDeadLetterQueue.arn,
    rule: myRule.name,
    inputPath: "
quot;,  //I have also tried with input: "" and get the same error
    batchTarget: {
        jobDefinition: myJob.arn,
        jobName: "My Job Name"
    }
});

What am I doing wrong? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文