首页 > 解决方案 > 如何在 serverless / cloudformation 中为合作伙伴事件总线创建事件规则

问题描述

我正在尝试为合作伙伴事件总线创建事件规则,arn:aws:events:{region}:{accountId}:event-bus/aws.partner/appflow/salesforce.com/{accountId}即将所有事件发送到无服务器中的 SQS 队列但运气不佳,我一直遇到此错误:

Serverless Error ----------------------------------------
  An error occurred: SFSubscriptionPartnerEventsRule - EventBus name starting with 'aws.' is not valid. (Service: AmazonCloudWatchEvents; Status Code: 400; Error Code: ValidationException; Request ID: ; Proxy: null).

对于上下文,合作伙伴事件总线名称是在创建 appflow 时自动生成的,因此无法aws在名称中避免。

我可以通过 AWS 控制台arn:aws:events:{region}:{accountId}:rule/aws.partner/appflow/salesforce.com/{accountId}/myPartnerEventRule1创建它,但真的很难通过无服务器 / cloudformation 创建它。

这是cloudformation的相关部分:

Type: AWS::Events::Rule
            Properties:
                Description: 'write salesforce subscription event to sqs'
                Name: 'events-${self:custom.deployingStage}-sfsubscriptionevent-sfsubscriptionsqs'
                EventBusName: 
                    Fn::GetAtt:
                        - CustomerPlatformSFPartnerEventBus
                        - Arn
                EventPattern:
                    account:
                        - Ref: 'AWS::AccountId'
                State: ENABLED
                Targets:
                    -   Arn:
                            Fn::GetAtt:
                                - SFSubscriptionToCustomerPlatformQueue
                                - Arn
                        Id: '${self:custom.queue.sfSubscriptionToCustomerPlatformQueue}'
                       

尝试了几件事无济于事:

有任何想法吗?

标签: amazon-web-servicesaws-event-bridgeserverless.com

解决方案


所以这也是我偶然发现的 AWS Cloudformation 中的一个错误。我联系了 AWS Support,得到了一些帮助(案例 ID 9092652141)。

这就是他们对这个问题所说的

对于此问题可能给您带来的任何不便,我深表歉意,我想通知您,我已就此行为与内部团队联系并要求调查此问题。

但是,在他们自己的环境中复制问题后,他们还提供了临时解决方法。

不要使用 Arn 或复制粘贴事件总线的名称,而是添加对事件总线名称的引用。我昨天尝试了这种方法,并成功创建了事件总线和规则。

话虽如此,至于现在为了创建事件规则,我会要求您传递事件总线的名称而不是 Arn。

Resources:
  EventBus:
    Type: AWS::Events::EventBus
    Properties:
      EventSourceName: <copy-paste the event source name of the partner here>
      Name: <Same as above>

  EventRule:
    Type: AWS::Events::Rule
    Properties:
      Name: <Event rule name>
      EventBusName: !GetAtt EventBus.Name

推荐阅读