我想在一個 AWS 帳戶中設定 Amazon EventBridge 規則,將事件傳送到另一個帳戶中的自訂事件匯流排。
解決方法
在目的地帳戶中建立事件匯流排,並設定以下資源型政策:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "WebStoreCrossAccountPublish",
"Effect": "Allow",
"Action": [
"events:PutEvents"
],
"Principal": {
"AWS": "arn:aws:iam::AccountA:root"
},
"Resource": "arn:aws:events:Region:AccountB:event-bus/central-event-bus"
}
]
}
**注意:**將 AccountA 替換為來源帳戶的 AWS 帳戶 ID,將 Region 替換為目的地帳戶的 AWS 區域,並將 AccountB 替換為目的地帳戶的帳戶 ID。
接著,完成以下步驟以設定規則:
- 在來源帳戶中開啟 EventBridge console (EventBridge 主控台)。
- 在導覽窗格中,選擇 Rules (規則),然後選擇 Create rule (建立規則)。
- 在 Select event bus (選取事件匯流排),選擇 AWS default event bus (AWS 預設事件匯流排)。
- 在 Select targets (選取目標),選擇 Target (目標),然後選擇 Event Bus in another AWS account (另一個 AWS 帳戶中的事件匯流排)。
- 選擇 Event Bus (事件匯流排),然後輸入目的地帳戶事件匯流排的 Amazon Resource Name (ARN)。
- 在 Role (角色),選取具有目的地事件匯流排 PutEvents 權限的 AWS Identity and Access Management (IAM) 角色。如果沒有現有角色可供使用,請建立 IAM 角色,並使用以下權限政策:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"events:PutEvents"
],
"Resource": [
"EventBusARN"
]
}
]
}
**注意:**將 EventBusARN 替換為目的地帳戶事件匯流排的 ARN。
- 選擇 Create rule (建立規則)。
相關資訊
在 Amazon EventBridge 中於 AWS 帳戶之間傳送和接收事件