View a markdown version of this page

使用 Amazon EventBridge 自動化 Savings Plans - Savings Plans

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

使用 Amazon EventBridge 自動化 Savings Plans

EventBridge 可協助您自動化 AWS 服務,並自動回應系統事件,例如應用程式可用性問題或資源變更。來自 AWS 服務的事件會以近乎即時的方式交付至 EventBridge。盡可能發出事件。根據您建立的規則,當事件符合您在規則中指定的值時,EventBridge 會呼叫一或多個目標動作。

可以自動觸發的動作如下:

  • 叫用 AWS Lambda 函數

  • 調用 Amazon EC2 執行命令

  • 將事件轉傳至 Amazon Kinesis Data Streams

  • 啟用 AWS Step Functions 狀態機器

  • 通知 Amazon SNS 主題或 AWS SMS 佇列

搭配 Savings Plans 使用 CloudWatch Events 的一些範例包括:

  • 在 Savings Plans 淘汰時啟用 Lambda 函數。

  • 標記 Savings Plans payment-failed或 時通知 Amazon SNS 主題active

如需詳細資訊,請參閱 Amazon CloudWatch Events 使用者指南

Savings Plans 中的範例事件

本節包含來自 Savings Plans 的範例事件。Savings Plans 會產生兩種類型的事件。狀態變更時觸發的狀態變更事件,以及狀態變更提醒事件,通知即將在一到七天內發生的狀態變更。

Savings Plans 狀態變更事件

Savings Plans 狀態變更會在 Savings Plans 從一個狀態轉換到另一個狀態時產生。例如,payment-pending狀態變更為 active,或active狀態變更為 retired

{ "version": "0", "id": "999cccaa-eaaa-0000-1111-123456789012", "detail-type": "Savings Plans State Change", "source": "aws.savingsplans", "account": "123456789012", "time": "2020-09-16T20:43:05Z", "region": "us-east-1", "resources": [ "arn:aws:savingsplans::123456789012:savingsplan/07ec53ab-91c3-4ac5-bde6-79fd53192252" ], "detail": { "severity": "INFO", "previousState": "payment-pending", "currentState": "active", "message": "PaymentSuccessful" } }

狀態變更事件包含資源 (Savings Plans ARNs)、先前狀態、目前狀態、嚴重性和訊息的欄位。

狀態變更事件的可能值
previousState currentState severity message
queued 付款待定 INFO

QueuedPurchaseFulfillment

queued 付款失敗 ERROR

LimitExceededException

SavingsPlanOfferingNotAvailableException

queued queued-deleted INFO

SavingsPlanQueuedDeleted

付款待定 active INFO

PaymentSuccessful

付款待定 付款失敗 ERROR

LimitExceededException

PaymentUnsuccessful

active 已淘汰 INFO

SavingsPlanExpiration

active 待傳回 INFO

SavingsPlanReturnRequested

待傳回 傳回 INFO

SavingsPlanReturnSuccessful

待傳回 active ERROR

SavingsPlanReturnUnsuccessful

Savings Plans 狀態變更提醒事件

Savings Plans 狀態變更提醒會在 Savings Plans 在一到七天retired內從 queued 狀態轉換為 activeactive 時產生。這是主動通知,可在任何 Savings Plans 正在淘汰或佇列狀態已履行時提醒您。

{ "version": "0", "id": "999cccaa-eaaa-0000-1111-123456789012", "detail-type": "Savings Plans State Changange Alert", "source": "aws.savingsplans", "account": "123456789012", "time": "2020-09-16T00:15:00Z", "region": "us-east-1", "resources": [ "arn:aws:savingsplans::123456789012:savingsplan/07ec53ab-91c3-4ac5-bde6-79fd53192252", "arn:aws:savingsplans::123456789012:savingsplan/19a9fa12-911a-18ed-9aa1-3a2615149a14" ], "detail": { "currentState": "queued", "nextState": "active", "remainingdays": "1", "nextStateChangeDate": "2020-09-17", "message": "queued savings plans will go to active state on 2020-09-17" } }

狀態變更提醒事件包含資源 (Savings Plans ARNs)、目前狀態、下一個狀態、剩餘天數、下一個狀態變更日期和訊息的欄位。

狀態變更提醒事件的可能值
currentState nextState remainingDays message

queued

active

1

排入佇列的 Savings Plans 會在 上進入作用中狀態YYYY-MM-DD

queued active 7

排入佇列的 Savings Plans 會在 上進入作用中狀態YYYY-MM-DD

active 已淘汰 1

作用中 Savings Plans 將在 上進入淘汰狀態YYYY-MM-DD

active 已淘汰 7

作用中 Savings Plans 將在 上進入淘汰狀態YYYY-MM-DD