无法使用 Pulumi 在自定义事件总线上创建事件规则。

huangapple go评论87阅读模式
英文:

Can't create event rule on custom event bus using Pulumi

问题

我在我的堆栈中有以下的Pulumi资源:

        ....
        var eventBus = new Aws.CloudWatch.EventBus("WebhookEventBus", new EventBusArgs()
        {
            Name = "WebhookEventBus"
        });

        var sendToApiRule = new Aws.CloudWatch.EventRule("SendToApi", new EventRuleArgs()
        {
            EventBusName = eventBus.Name,
            EventPattern = @"{
                ""source"": [{ ""prefix"": ""xxxx"" }]
            }"
        });

        var devTarget = new Aws.CloudWatch.EventTarget("DevTarget", new EventTargetArgs()
        {
            Rule = sendToApiRule.Name,
            Arn = apiDestination.Arn,
            RoleArn = apiDestinationRole.Arn
        });

在创建我的Pulumi堆栈时,我收到以下错误:

creating EventBridge Target (SendToApi-30d74a6-DevTarget-1b917a0): ResourceNotFoundException: Rule SendToApi-30d74a6 does not exist on EventBus default.

事实上,CloudTrail似乎证实了这个错误来自于events.amazonaws.com

    ...
    "errorCode": "InternalFailure",
    "errorMessage": "An unknown error occurred",
    "requestParameters": {
        "rule": "SendToApi-8e734a8",
        "eventBusName": "default",
        "targets": [
            {
                "id": "DevTarget-eb8e26d",
                "arn": "xxxx",
                "roleArn": "xxxx"
            }
        ]
    },
    ...

我尝试过在EventBusName中使用静态字符串“WebhookEventBus”。我也尝试过将这些事件包装在.Apply(x => )语句中,但总是收到这个错误。你有任何可能的原因吗?

英文:

I have the following Pulumi resources in my stack:

        ....
        var eventBus = new Aws.CloudWatch.EventBus("WebhookEventBus", new EventBusArgs()
        {
            Name = "WebhookEventBus"
        });

        var sendToApiRule = new Aws.CloudWatch.EventRule("SendToApi", new EventRuleArgs()
        {
            EventBusName = eventBus.Name,
            EventPattern = @"{
                ""source"": [{ ""prefix"": ""xxxx"" }]
            }"
        });

        var devTarget = new Aws.CloudWatch.EventTarget("DevTarget", new EventTargetArgs()
        {
            Rule = sendToApiRule.Name,
            Arn = apiDestination.Arn,
            RoleArn = apiDestinationRole.Arn
        });

When creating my Pulumi Stack, I get the error:

creating EventBridge Target (SendToApi-30d74a6-DevTarget-1b917a0): ResourceNotFoundException: Rule SendToApi-30d74a6 does not exist on EventBus default.

Indeed, CloudTrail seems to confirm this error originating from events.amazonaws.com:

    ...
    "errorCode": "InternalFailure",
    "errorMessage": "An unknown error occurred",
    "requestParameters": {
        "rule": "SendToApi-8e734a8",
        "eventBusName": "default",
        "targets": [
            {
                "id": "DevTarget-eb8e26d",
                "arn": "xxxx",
                "roleArn": "xxxx"
            }
        ]
    },
    ...

I've tried using a static string "WebhookEventBus" in EventBusName. I've also tried wrapping these events in .Apply(x => ) statements, but always receive this error. Any idea why this might be?

答案1

得分: 1

你需要根据以下链接中的说明指定EventBusName属性:

https://www.pulumi.com/registry/packages/aws/api-docs/cloudwatch/eventtarget/#eventbusname_csharp

目前它正在使用"default"事件总线,因此无法找到规则。

英文:

You need to specify the EventBusName property as per:

https://www.pulumi.com/registry/packages/aws/api-docs/cloudwatch/eventtarget/#eventbusname_csharp

Currently, it's using the "default" event bus and so can't find the rule.

huangapple
  • 本文由 发表于 2023年7月14日 04:33:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/76683058.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定