本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
Amazon EventBridge 的 Amazon EBS
Amazon EBS 會將事件傳送至 Amazon EventBridge ,以便在磁碟區和快照上執行的動作。使用 EventBridge,您可以建立規則來觸發程式設計動作以回應這些事件。例如,您可以建立規則,從而在啟用快照進行快速快照還原時,將通知傳送至您的電子郵件。
中的事件 EventBridge 會以 JSON 物件表示。事件的獨特欄位會包含在 JSON 物件的 "detail" 區段中。"event" 欄位則包含事件名稱。"result" 欄位包含觸發事件之動作的完成狀態。如需詳細資訊,請參閱 Amazon EventBridge 使用者指南中的 Amazon EventBridge 事件模式。
有關更多信息,請參閱什麼是 Amazon EventBridge? 在 Amazon 用 EventBridge 戶指南。
EBS 磁碟區事件
Amazon EBS 會在發生下列磁碟區事件 EventBridge 時傳送事件。
建立磁碟區 (createVolume)
建立磁碟區的動作完成時,會將createVolume
事件傳送至您的 AWS 帳戶。但不會儲存、記錄或存檔。此事件的結果可以是 available
或 failed
。如果提供無效 AWS KMS key 的話,建立將會失敗,如下列範例所示。
事件資料
下列清單為 EBS 針對成功的 createVolume
事件發出的 JSON 物件範例。
{
"version": "0",
"id": "01234567
-0123
-0123
-0123
-012345678901
",
"detail-type": "EBS Volume Notification",
"source": "aws.ec2",
"account": "012345678901
",
"time": "yyyy
-mm
-dd
Thh
:mm
:ss
Z",
"region": "us-east-1
",
"resources": [
"arn:aws:ec2:us-east-1
:012345678901
:volume/vol-01234567
"
],
"detail": {
"result": "available",
"cause": "",
"event": "createVolume",
"request-id": "01234567
-0123
-0123
-0123
-0123456789ab
"
}
}
下列清單為 EBS 針對失敗的 createVolume
事件發出的 JSON 物件範例。失敗原因為 KMS 金鑰 已停用。
{
"version": "0",
"id": "01234567
-0123
-0123
-0123
-0123456789ab
",
"detail-type": "EBS Volume Notification",
"source": "aws.ec2",
"account": "012345678901
",
"time": "yyyy
-mm
-dd
Thh
:mm
:ss
Z",
"region": "sa-east-1
",
"resources": [
"arn:aws:ec2:sa-east-1
:0123456789ab
:volume/vol-01234567
",
],
"detail": {
"event": "createVolume",
"result": "failed",
"cause": "arn:aws:kms:sa-east-1
:0123456789ab
:key/01234567
-0123
-0123
-0123
-0123456789ab
is disabled.",
"request-id": "01234567
-0123
-0123
-0123
-0123456789ab
",
}
}
以下為 EBS 針對失敗的 createVolume
事件發出的 JSON 物件範例。失敗原因為 KMS 金鑰 正在等待匯入。
{
"version": "0",
"id": "01234567
-0123
-0123
-0123
-0123456789ab
",
"detail-type": "EBS Volume Notification",
"source": "aws.ec2",
"account": "012345678901
",
"time": "yyyy
-mm
-dd
Thh
:mm
:ss
Z",
"region": "sa-east-1
",
"resources": [
"arn:aws:ec2:sa-east-1
:0123456789ab
:volume/vol-01234567
",
],
"detail": {
"event": "createVolume",
"result": "failed",
"cause": "arn:aws:kms:sa-east-1
:0123456789ab
:key/01234567
-0123
-0123
-0123
-0123456789ab
is pending import.",
"request-id": "01234567
-0123
-0123
-0123
-0123456789ab
",
}
}
刪除磁碟區 (deleteVolume)
刪除磁碟區的動作完成後,會將deleteVolume
事件傳送至您的 AWS 帳戶。但不會儲存、記錄或存檔。此事件的結果為 deleted
。若刪除未完成,便不會傳送該事件。
事件資料
下列清單為 EBS 針對成功的 deleteVolume
事件發出的 JSON 物件範例。
{
"version": "0",
"id": "01234567
-0123
-0123
-0123
-012345678901
",
"detail-type": "EBS Volume Notification",
"source": "aws.ec2",
"account": "012345678901
",
"time": "yyyy
-mm
-dd
Thh
:mm
:ss
Z",
"region": "us-east-1
",
"resources": [
"arn:aws:ec2:us-east-1
:012345678901
:volume/vol-01234567
"
],
"detail": {
"result": "deleted",
"cause": "",
"event": "deleteVolume",
"request-id": "01234567
-0123
-0123
-0123
-0123456789ab
"
}
}
磁碟區連接或重新連接 (attachVolume、reattachVolume)
attachVolume
或 reattachVolume
事件會在磁碟區連接或重新連接到執行個體失敗時傳送到您的 AWS 帳戶。但不會儲存、記錄或存檔。若您使用 KMS 金鑰 加密 EBS 磁碟區但 KMS 金鑰 卻失效,EBS 便會在稍後使用該 KMS 金鑰 來連接或重新連接到執行個體時發出此事件,如以下範例所示。
事件資料
下列清單為 EBS 針對失敗的 attachVolume
事件發出的 JSON 物件範例。失敗原因為 KMS 金鑰 正在等待刪除。
注意
AWS 在伺服器例行維護之後,可能會嘗試重新連接到磁碟區。
{
"version": "0",
"id": "01234567
-0123
-0123
-0123
-0123456789ab
",
"detail-type": "EBS Volume Notification",
"source": "aws.ec2",
"account": "012345678901
",
"time": "yyyy
-mm
-dd
Thh
:mm
:ss
Z",
"region": "us-east-1
",
"resources": [
"arn:aws:ec2:us-east-1
:0123456789ab
:volume/vol-01234567
",
"arn:aws:kms:us-east-1
:0123456789ab
:key/01234567
-0123
-0123
-0123
-0123456789ab
"
],
"detail": {
"event": "attachVolume",
"result": "failed",
"cause": "arn:aws:kms:us-east-1
:0123456789ab
:key/01234567
-0123
-0123
-0123
-0123456789ab
is pending deletion.",
"request-id": ""
}
}
下列清單為 EBS 針對失敗的 reattachVolume
事件發出的 JSON 物件範例。失敗原因為 KMS 金鑰 正在等待刪除。
{
"version": "0",
"id": "01234567
-0123
-0123
-0123
-0123456789ab
",
"detail-type": "EBS Volume Notification",
"source": "aws.ec2",
"account": "012345678901
",
"time": "yyyy
-mm
-dd
Thh
:mm
:ss
Z",
"region": "us-east-1
",
"resources": [
"arn:aws:ec2:us-east-1
:0123456789ab
:volume/vol-01234567
",
"arn:aws:kms:us-east-1
:0123456789ab
:key/01234567
-0123
-0123
-0123
-0123456789ab
"
],
"detail": {
"event": "reattachVolume",
"result": "failed",
"cause": "arn:aws:kms:us-east-1
:0123456789ab
:key/01234567
-0123
-0123
-0123
-0123456789ab
is pending deletion.",
"request-id": ""
}
}
分離磁碟區 (detachVolume)
當磁碟區與 Amazon EC2 執行個體分離時,會將detachVolume
事件傳送至您的 AWS 帳戶。
事件資料
以下是成功detachVolume
事件的範例。
{
"version":"0",
"id":"2ec37298-1234-e436-70fc-c96b1example
",
"detail-type":"AWS API Call via CloudTrail",
"source":"aws.ec2",
"account":"123456789012
",
"time":"2024-03-18T16:35:52Z
",
"region":"us-east-1
",
"resources":[],
"detail":
{
"eventVersion":"1.09",
"userIdentity":
{
"type":"IAMUser",
"principalId":"AIDAJT12345SQ2EXAMPLE
",
"arn":"arn:aws:iam::123456789012:user/administrator"
,
"accountId":"123456789012"
,
"accessKeyId":"AKIAJ67890A6EXAMPLE"
,
"userName":"administrator
"
},
"eventTime":"2024-03-18T16:35:52Z
",
"eventSource":"ec2.amazonaws.com",
"eventName":"DetachVolume",
"awsRegion":"us-east-1
",
"sourceIPAddress":"12.12.123.12
",
"userAgent":"aws-cli/2.7.12 Python/3.9.11 Windows/10 exe/AMD64 prompt/off command/ec2.detach-volume",
"requestParameters":
{
"volumeId":"vol-072577c46bexample
",
"force":false
},
"responseElements":
{
"requestId":"1234513a-6292-49ea-83f8-85e95example
",
"volumeId":"vol-072577c46bexample
",
"instanceId":"i-0217f7eb3dexample
",
"device":"/dev/sdb
",
"status":"detaching",
"attachTime":1710776815000
},
"requestID":"1234513a-6292-49ea-83f8-85e95example
",
"eventID":"1234551d-a15a-43eb-9e69-c983aexample
",
"readOnly":false,
"eventType":"AwsApiCall",
"managementEvent":true,
"recipientAccountId":"123456789012
",
"eventCategory":"Management",
"tlsDetails":
{
"tlsVersion":"TLSv1.3",
"cipherSuite":"TLS_AES_128_GCM_SHA256",
"clientProvidedHostHeader":"ec2.us-east-1.amazonaws.com
"
}
}
}
EBS 磁碟區修改事件
Amazon EBS 會在磁碟區修改 EventBridge 時傳送modifyVolume
事件。但不會儲存、記錄或存檔。
{
"version": "0",
"id": "01234567
-0123
-0123
-0123
-012345678901
",
"detail-type": "EBS Volume Notification",
"source": "aws.ec2",
"account": "012345678901
",
"time": "yyyy
-mm
-dd
Thh
:mm
:ss
Z",
"region": "us-east-1
",
"resources": [
"arn:aws:ec2:us-east-1
:012345678901
:volume/vol-03a55cf56513fa1b6
"
],
"detail": {
"result": "optimizing
",
"cause": "",
"event": "modifyVolume",
"request-id": "01234567
-0123
-0123
-0123
-0123456789ab
"
}
}
EBS 快照事件
Amazon EBS 會在發生下列磁碟區事件 EventBridge 時傳送事件。
建立快照 (createSnapshot)
建立快照的動作完成時,會將createSnapshot
事件傳送至您的 AWS 帳戶。但不會儲存、記錄或存檔。此事件的結果可以是 succeeded
或 failed
。
事件資料
下列清單為 EBS 針對成功的 createSnapshot
事件發出的 JSON 物件範例。在 detail
區段中,source
欄位包含來源磁碟區的 ARN。startTime
和 endTime
欄位則表示開始建立快照和完成建立的時間。
{
"version": "0",
"id": "01234567
-0123
-0123
-0123
-012345678901
",
"detail-type": "EBS Snapshot Notification",
"source": "aws.ec2",
"account": "012345678901
",
"time": "yyyy
-mm
-dd
Thh
:mm
:ss
Z",
"region": "us-east-1
",
"resources": [
"arn:aws:ec2::us-west-2
:snapshot/snap-01234567
"
],
"detail": {
"event": "createSnapshot",
"result": "succeeded",
"cause": "",
"request-id": "",
"snapshot_id": "arn:aws:ec2::us-west-2
:snapshot/snap-01234567
",
"source": "arn:aws:ec2::us-west-2
:volume/vol-01234567
",
"startTime": "yyyy
-mm
-dd
Thh
:mm
:ss
Z",
"endTime": "yyyy
-mm
-dd
Thh
:mm
:ss
Z" }
}
建立快照 (createSnapshots)
建立多磁碟區快照的動作完成時,createSnapshots
事件會傳送至您的 AWS 帳戶。此事件的結果可以是 succeeded
或 failed
。
事件資料
下列清單為 EBS 針對成功的 createSnapshots
事件發出的 JSON 物件範例。在 detail
區段中,source
欄位包含多磁碟區快照集的來源磁碟區的 ARN。startTime
和 endTime
欄位則表示開始建立快照和完成建立的時間。
{
"version": "0",
"id": "01234567-0123-0123-0123-012345678901
",
"detail-type": "EBS Multi-Volume Snapshots Completion Status",
"source": "aws.ec2",
"account": "012345678901
",
"time": "yyyy
-mm
-dd
Thh
:mm
:ss
Z",
"region": "us-east-1
",
"resources": [
"arn:aws:ec2::us-east-1
:snapshot/snap-01234567
",
"arn:aws:ec2::us-east-1
:snapshot/snap-012345678
"
],
"detail": {
"event": "createSnapshots",
"result": "succeeded",
"cause": "",
"request-id": "",
"startTime": "yyyy
-mm
-dd
Thh
:mm
:ss
Z",
"endTime": "yyyy
-mm
-dd
Thh
:mm
:ss
Z",
"snapshots": [
{
"snapshot_id": "arn:aws:ec2::us-east-1
:snapshot/snap-01234567
",
"source": "arn:aws:ec2::us-east-1
:volume/vol-01234567
",
"status": "completed"
},
{
"snapshot_id": "arn:aws:ec2::us-east-1
:snapshot/snap-012345678
",
"source": "arn:aws:ec2::us-east-1
:volume/vol-012345678
",
"status": "completed"
}
]
}
}
下列清單為 EBS 針對失敗的 createSnapshots
事件發出的 JSON 物件範例。失敗原因是多磁碟區快照集的一或多個快照無法完成。snapshot_id
的值是失敗快照的 ARN。startTime
和 endTime
代表建立快照動作何時開始和結束。
{
"version": "0",
"id": "01234567-0123-0123-0123-012345678901
",
"detail-type": "EBS Multi-Volume Snapshots Completion Status",
"source": "aws.ec2",
"account": "012345678901
",
"time": "yyyy-mm-ddThh:mm:ssZ
",
"region": "us-east-1
",
"resources": [
"arn:aws:ec2::us-east-1
:snapshot/snap-01234567
",
"arn:aws:ec2::us-east-1
:snapshot/snap-012345678
"
],
"detail": {
"event": "createSnapshots",
"result": "failed",
"cause": "Snapshot snap-01234567 is in status error",
"request-id": "",
"startTime": "yyyy-mm-ddThh:mm:ssZ
",
"endTime": "yyyy-mm-ddThh:mm:ssZ
",
"snapshots": [
{
"snapshot_id": "arn:aws:ec2::us-east-1
:snapshot/snap-01234567
",
"source": "arn:aws:ec2::us-east-1
:volume/vol-01234567
",
"status": "error"
},
{
"snapshot_id": "arn:aws:ec2::us-east-1
:snapshot/snap-012345678
",
"source": "arn:aws:ec2::us-east-1
:volume/vol-012345678
",
"status": "error"
}
]
}
}
複製快照 (copySnapshot)
複製快照的動作完成時,會將copySnapshot
事件傳送至您的 AWS 帳戶。但不會儲存、記錄或存檔。此事件的結果可以是 succeeded
或 failed
。
如果要跨區域複製快照,則會在目的地區域中發出事件。
事件資料
下列清單為 EBS 在成功的 copySnapshot
事件之後發出的 JSON 物件範例。snapshot_id
的值為新建立之快照的 ARN。在 detail
區段中,值 source
是來源快照的 ARN。startTime
和 endTime
代表 copy-snapshot 動作的開始和結束時間。incremental
指出快照是增量快照 (true
) 還是完整快照 (false
)。
{
"version": "0",
"id": "01234567
-0123
-0123
-0123
-012345678901
",
"detail-type": "EBS Snapshot Notification",
"source": "aws.ec2",
"account": "123456789012
",
"time": "yyyy
-mm
-dd
Thh
:mm
:ss
Z",
"region": "us-east-1
",
"resources": [
"arn:aws:ec2::us-west-2
:snapshot/snap-01234567
"
],
"detail": {
"event": "copySnapshot",
"result": "succeeded",
"cause": "",
"request-id": "",
"snapshot_id": "arn:aws:ec2::us-west-2
:snapshot/snap-01234567
",
"source": "arn:aws:ec2::eu-west-1
:snapshot/snap-76543210
",
"startTime": "yyyy
-mm
-dd
Thh
:mm
:ss
Z",
"endTime": "yyyy
-mm
-dd
Thh
:mm
:ss
Z",
"incremental": "true"
}
}
下列清單為 EBS 針對失敗的 copySnapshot
事件發出的 JSON 物件範例。導致此失敗的原因為來源快照 ID 無效。snapshot_id
的值為失敗快照的 ARN。在 detail
區段中,source
的值是來源快照的 ARN。startTime
和 endTime
代表複製快照動作時開始和結束的時間。
{
"version": "0",
"id": "01234567
-0123
-0123
-0123
-012345678901
",
"detail-type": "EBS Snapshot Notification",
"source": "aws.ec2",
"account": "123456789012
",
"time": "yyyy
-mm
-dd
Thh
:mm
:ss
Z",
"region": "us-east-1
",
"resources": [
"arn:aws:ec2::us-west-2
:snapshot/snap-01234567
"
],
"detail": {
"event": "copySnapshot",
"result": "failed",
"cause": "Source snapshot ID is not valid",
"request-id": "",
"snapshot_id": "arn:aws:ec2::us-west-2
:snapshot/snap-01234567
",
"source": "arn:aws:ec2::eu-west-1
:snapshot/snap-76543210
",
"startTime": "yyyy
-mm
-dd
Thh
:mm
:ss
Z",
"endTime": "yyyy
-mm
-dd
Thh
:mm
:ss
Z"
}
}
共用快照 (shareSnapshot)
當另一個 AWS 帳戶與其共享快照時,shareSnapshot
事件便會傳送至您的帳戶。但不會儲存、記錄或存檔。結果一律為 succeeded
。
事件資料
以下為 EBS 在完成的 shareSnapshot
事件之後發出的 JSON 物件範例。在detail
區段中,的值source
是與您共用快照之使用者的 AWS 帳號。 startTime
並endTime
表示共用快照動作的開始和結束時間。shareSnapshot
事件只會在與另一個使用者共享私有快照時發出。共享公有快照不會觸發事件。
{
"version": "0",
"id": "01234567
-01234
-0123
-0123
-012345678901
",
"detail-type": "EBS Snapshot Notification",
"source": "aws.ec2",
"account": "012345678901
",
"time": "yyyy
-mm
-dd
Thh
:mm
:ss
Z",
"region": "us-east-1
",
"resources": [
"arn:aws:ec2::us-west-2
:snapshot/snap-01234567
"
],
"detail": {
"event": "shareSnapshot",
"result": "succeeded",
"cause": "",
"request-id": "",
"snapshot_id": "arn:aws:ec2::us-west-2
:snapshot/snap-01234567
",
"source": 012345678901
,
"startTime": "yyyy
-mm
-dd
Thh
:mm
:ss
Z",
"endTime": "yyyy
-mm
-dd
Thh
:mm
:ss
Z"
}
}
EBS 快照封存事件
Amazon EBS 會發出與快照封存動作相關的事件。如需詳細資訊,請參閱 監控快照封存。
EBS 快速快照還原事件
Amazon EBS 會在快照快照還原狀態變更 EventBridge 時傳送事件。盡可能發出事件。
以下是此事件的範例資料。
{
"version": "0",
"id": "01234567
-0123
-0123
-0123
-012345678901
",
"detail-type": "EBS Fast Snapshot Restore State-change Notification",
"source": "aws.ec2",
"account": "123456789012
",
"time": "yyyy
-mm
-dd
Thh
:mm
:ss
Z",
"region": "us-east-1
",
"resources": [
"arn:aws:ec2:us-east-1
::snapshot/snap-03a55cf56513fa1b6
"
],
"detail": {
"snapshot-id": "snap-1234567890abcdef0
",
"state": "optimizing
",
"zone": "us-east-1a
",
"message": "Client.UserInitiated - Lifecycle state transition
",
}
}
state
的可能值為 enabling
、optimizing
、enabled
、disabling
和 disabled
。
message
可能的值如下:
Client.InvalidSnapshot.InvalidState - The requested snapshot transitioned to an invalid state (Error)
-
啟用快速快照還原的請求已失敗,並且狀態轉換成
disabling
或disabled
。無法為此快照啟用快速快照還原。 Client.UserInitiated
-
狀態已成功轉換成
enabling
或disabling
。 Client.UserInitiated - Lifecycle state transition
-
狀態已成功轉換成
optimizing
、enabled
或disabled
。 Server.InsufficientCapacity - There was insufficient capacity available to satisfy the request
-
由於不足夠的容量,啟用快速快照還原的請求已失敗,並且狀態轉換成
disabling
或disabled
。等候然後再試一次。 Server.InternalError - An internal error caused the operation to fail
-
由於內部錯誤,啟用快速快照還原的請求已失敗,並且狀態轉換成
disabling
或disabled
。等候然後再試一次。 Client.InvalidSnapshot.InvalidState - The requested snapshot was deleted or access permissions were revoked
-
快照的快速快照還原狀態已轉換為
disabling
或disabled
,因為快照擁有者已將快照刪除或取消共享。您無法針對已刪除或不再與您共享的快照啟用快速快照還原。
用 AWS Lambda 來處理 EventBridge 事件
您可以使用 Amazon EBS 和 Amazon EventBridge 來自動化您的資料備份工作流程。這需要您建立 IAM 政策、處理事件的 AWS Lambda 函數,以及符合傳入事件並將其路由至 Lambda 函數的 EventBridge規則。
下列程序使用 createSnapshot
事件自動將完成的快照複製到另一個區域,做為災難復原用途。
將完成的快照複製到另一個區域
-
建立 IAM 政策 (例如以下範例所示),以提供使用
CopySnapshot
動作和寫入 EventBridge 記錄的許可。將原則指派給將處理 EventBridge 事件的使用者。{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents" ], "Resource": "arn:aws:logs:*:*:*" }, { "Effect": "Allow", "Action": [ "ec2:CopySnapshot" ], "Resource": "*" } ] }
-
在 Lambda 中定義可從 EventBridge 主控台使用的函數。以下以 Node.js 撰寫的範例 Lambda 函數會在 Amazon EBS 發出相符
createSnapshot
事件 EventBridge 時叫用 (表示快照已完成)。當呼叫時,函數會將快照從us-east-2
複製到us-east-1
。// Sample Lambda function to copy an EBS snapshot to a different Region var AWS = require('aws-sdk'); var ec2 = new AWS.EC2(); // define variables var destinationRegion = '
us-east-1
'; var sourceRegion = 'us-east-2
'; console.log ('Loading function'); //main function exports.handler = (event, context, callback) => { // Get the EBS snapshot ID from the event details var snapshotArn = event.detail.snapshot_id.split('/'); const snapshotId = snapshotArn[1]; const description = `Snapshot copy from ${snapshotId} in ${sourceRegion}.`; console.log ("snapshotId:", snapshotId); // Load EC2 class and update the configuration to use destination Region to initiate the snapshot. AWS.config.update({region: destinationRegion}); var ec2 = new AWS.EC2(); // Prepare variables for ec2.modifySnapshotAttribute call const copySnapshotParams = { Description: description, DestinationRegion: destinationRegion, SourceRegion: sourceRegion, SourceSnapshotId: snapshotId }; // Execute the copy snapshot and log any errors ec2.copySnapshot(copySnapshotParams, (err, data) => { if (err) { const errorMessage = `Error copying snapshot ${snapshotId} to Region ${destinationRegion}.`; console.log(errorMessage); console.log(err); callback(errorMessage); } else { const successMessage = `Successfully started copy of snapshot ${snapshotId} to Region ${destinationRegion}.`; console.log(successMessage); console.log(data); callback(null, successMessage); } }); };若要確保您的 Lambda 函數可從 EventBridge 主控台使用,請在將發生 EventBridge 事件的區域中建立該函數。如需詳細資訊,請參閱《AWS Lambda 開發人員指南》。
在以下位置打開 Amazon EventBridge 控制台 https://console.aws.amazon.com/events/
。 -
在導覽窗格中,選擇 Rules (規則),然後選擇 Create rule (建立規則)。
-
對於 Step 1: Define rule detail (步驟 1:定義規則詳細資訊),執行下列動作:
-
輸入 Name (名稱) 與 Description (描述) 的值。
-
針對 Event bus (事件匯流排),保持 default (預設值)。
-
確保 Enable the rule on the selected event bus (在選取的事件匯流排上啟用規則) 已開啟。
-
對於 Event type (事件類型),選取 Rule with an event pattern (具有事件模式的規則)。
-
選擇下一步。
-
-
對於 Step 2: Build event pattern (步驟 2:建置事件模式),執行下列動作:
-
對於事件來源,請選取AWS 事件或 EventBridge 合作夥伴事件。
-
在事件模式區段中,對於事件來源,確保已選取 AWS 服務,對於 AWS 服務,選取 EC2。
-
對於 Event type (事件類型),選取 EBS Snapshot Notification (EBS 快照通知),選取 Specific event(s) (特定事件),然後選取 createSnapshot (建立快照)。
-
選取 Specific result(s) (特定結果),然後選取 succeeded (成功)。
-
選擇下一步。
-
-
對於 Step 3: Select targets (步驟 3:選取目標),執行下列動作:
-
在目標類型欄位中,選擇 AWS 服務。
-
對於 Select target (選取目標),選取 Lambda function (Lambda 函數),並為 Function (函數) 選取您先前建立的函數。
-
選擇 Next (下一步)
-
-
對於 Step 4: Configure tags (步驟 4:設定標籤),視需要指定規則的標籤,然後選擇 Next (下一步)。
-
對於 Step 5: Review and create (步驟 5:檢閱和建立),檢閱規則,然後選擇 Create rule (建立規則)。
您的規則現在應該會出現在 Rules (規則) 標籤上。在上述範例中,EBS 應該會在您下次複製快照時發出所設定的事件。