Budget AWS esempi utilizzando AWS CLI - AWS Command Line Interface

Questa documentazione è valida AWS CLI solo per la versione 1. Per la documentazione relativa alla versione 2 di AWS CLI, consulta la Guida per l'utente della versione 2.

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

Budget AWS esempi utilizzando AWS CLI

I seguenti esempi di codice mostrano come eseguire azioni e implementare scenari comuni utilizzando AWS Command Line Interface with Budget AWS.

Le azioni sono estratti di codice da programmi più grandi e devono essere eseguite nel contesto. Sebbene le azioni mostrino come richiamare le singole funzioni del servizio, è possibile visualizzarle contestualizzate negli scenari correlati.

Ogni esempio include un link al codice sorgente completo, in cui vengono fornite le istruzioni su come configurare ed eseguire il codice nel contesto.

Argomenti

Azioni

Il seguente esempio di codice mostra come utilizzarecreate-budget.

AWS CLI

Come creare un budget di utilizzo e costi

Il comando create-budget seguente crea un budget di utilizzo e costi.

aws budgets create-budget \ --account-id 111122223333 \ --budget file://budget.json \ --notifications-with-subscribers file://notifications-with-subscribers.json

Contenuto di budget.json:

{ "BudgetLimit": { "Amount": "100", "Unit": "USD" }, "BudgetName": "Example Tag Budget", "BudgetType": "COST", "CostFilters": { "TagKeyValue": [ "user:Key$value1", "user:Key$value2" ] }, "CostTypes": { "IncludeCredit": true, "IncludeDiscount": true, "IncludeOtherSubscription": true, "IncludeRecurring": true, "IncludeRefund": true, "IncludeSubscription": true, "IncludeSupport": true, "IncludeTax": true, "IncludeUpfront": true, "UseBlended": false }, "TimePeriod": { "Start": 1477958399, "End": 3706473600 }, "TimeUnit": "MONTHLY" }

Contenuto di notifications-with-subscribers.json:

[ { "Notification": { "ComparisonOperator": "GREATER_THAN", "NotificationType": "ACTUAL", "Threshold": 80, "ThresholdType": "PERCENTAGE" }, "Subscribers": [ { "Address": "example@example.com", "SubscriptionType": "EMAIL" } ] } ]

Il seguente esempio di codice mostra come utilizzarecreate-notification.

AWS CLI

Come creare una notifica per il budget di costi e utilizzo specificato

Questo esempio crea una notifica per il budget di costi e utilizzo specificato.

Comando:

aws budgets create-notification --account-id 111122223333 --budget-name "Example Budget" --notification NotificationType=ACTUAL,ComparisonOperator=GREATER_THAN,Threshold=80,ThresholdType=PERCENTAGE --subscriber SubscriptionType=EMAIL,Address=example@example.com

Il seguente esempio di codice mostra come utilizzarecreate-subscriber.

AWS CLI

Come creare un abbonato per una notifica associata a un budget di costi e utilizzo

Questo esempio crea un abbonato per la notifica specificata.

Comando:

aws budgets create-subscriber --account-id 111122223333 --budget-name "Example Budget" --notification NotificationType=ACTUAL,ComparisonOperator=GREATER_THAN,Threshold=80,ThresholdType=PERCENTAGE --subscriber SubscriptionType=EMAIL,Address=example@example.com

Il seguente esempio di codice mostra come utilizzaredelete-budget.

AWS CLI

Come eliminare un budget di costi e utilizzo

Questo esempio elimina il budget di costi e utilizzo specificato.

Comando:

aws budgets delete-budget --account-id 111122223333 --budget-name "Example Budget"

Il seguente esempio di codice mostra come utilizzaredelete-notification.

AWS CLI

Come eliminare una notifica da un budget

In questo esempio viene eliminata la notifica specificata dal budget specificato.

Comando:

aws budgets delete-notification --account-id 111122223333 --budget-name "Example Budget" --notification NotificationType=ACTUAL,ComparisonOperator=GREATER_THAN,Threshold=80,ThresholdType=PERCENTAGE

Il seguente esempio di codice mostra come utilizzaredelete-subscriber.

AWS CLI

Come eliminare un abbonato da una notifica

In questo esempio viene eliminato l’abbonato specificato dalla notifica specificata.

Comando:

aws budgets delete-subscriber --account-id 111122223333 --budget-name "Example Budget" --notification NotificationType=ACTUAL,ComparisonOperator=GREATER_THAN,Threshold=80,ThresholdType=PERCENTAGE --subscriber SubscriptionType=EMAIL,Address=example@example.com

Il seguente esempio di codice mostra come utilizzaredescribe-budget.

AWS CLI

Come recuperare un budget associato a un account

Questo esempio recupera il budget di costi e utilizzo specificato.

Comando:

aws budgets describe-budget --account-id 111122223333 --budget-name "Example Budget"

Output:

{ "Budget": { "CalculatedSpend": { "ForecastedSpend": { "Amount": "2641.54800000000022919266484677791595458984375", "Unit": "USD" }, "ActualSpend": { "Amount": "604.4560000000000172803993336856365203857421875", "Unit": "USD" } }, "BudgetType": "COST", "BudgetLimit": { "Amount": "100", "Unit": "USD" }, "BudgetName": "Example Budget", "CostTypes": { "IncludeOtherSubscription": true, "IncludeUpfront": true, "IncludeRefund": true, "UseBlended": false, "IncludeDiscount": true, "UseAmortized": false, "IncludeTax": true, "IncludeCredit": true, "IncludeSupport": true, "IncludeRecurring": true, "IncludeSubscription": true }, "TimeUnit": "MONTHLY", "TimePeriod": { "Start": 1477958399.0, "End": 3706473600.0 }, "CostFilters": { "AZ": [ "us-east-1" ] } } }

Il seguente esempio di codice mostra come utilizzaredescribe-budgets.

AWS CLI

Come recuperare i budget associati a un account

Questo esempio recupera i budget di costo e utilizzo per un account.

Comando:

aws budgets describe-budgets --account-id 111122223333 --max-results 20

Output:

{ "Budgets": [ { "CalculatedSpend": { "ForecastedSpend": { "Amount": "2641.54800000000022919266484677791595458984375", "Unit": "USD" }, "ActualSpend": { "Amount": "604.4560000000000172803993336856365203857421875", "Unit": "USD" } }, "BudgetType": "COST", "BudgetLimit": { "Amount": "100", "Unit": "USD" }, "BudgetName": "Example Budget", "CostTypes": { "IncludeOtherSubscription": true, "IncludeUpfront": true, "IncludeRefund": true, "UseBlended": false, "IncludeDiscount": true, "UseAmortized": false, "IncludeTax": true, "IncludeCredit": true, "IncludeSupport": true, "IncludeRecurring": true, "IncludeSubscription": true }, "TimeUnit": "MONTHLY", "TimePeriod": { "Start": 1477958399.0, "End": 3706473600.0 }, "CostFilters": { "AZ": [ "us-east-1" ] } } ] }

Il seguente esempio di codice mostra come utilizzaredescribe-notifications-for-budget.

AWS CLI

Come recuperare le notifiche relative a un budget

Questo esempio recupera le notifiche relative a un budget di costi e utilizzo.

Comando:

aws budgets describe-notifications-for-budget --account-id 111122223333 --budget-name "Example Budget" --max-results 5

Output:

{ "Notifications": [ { "Threshold": 80.0, "ComparisonOperator": "GREATER_THAN", "NotificationType": "ACTUAL" } ] }

Il seguente esempio di codice mostra come utilizzaredescribe-subscribers-for-notification.

AWS CLI

Come recuperare gli abbonati per una notifica relativa a un budget

Questo esempio recupera gli abbonati per una notifica relativa al budget di costi e utilizzo.

Comando:

aws budgets describe-subscribers-for-notification --account-id 111122223333 --budget-name "Example Budget" --notification NotificationType=ACTUAL,ComparisonOperator=GREATER_THAN,Threshold=80,ThresholdType=PERCENTAGE --max-results 5

Output:

{ "Subscribers": [ { "SubscriptionType": "EMAIL", "Address": "example2@example.com" }, { "SubscriptionType": "EMAIL", "Address": "example@example.com" } ] }

Il seguente esempio di codice mostra come utilizzareupdate-budget.

AWS CLI

Come sostituire un budget con un budget di costi e utilizzo

Questo esempio sostituisce un budget di costi e utilizzo con un nuovo budget.

Comando:

aws budgets update-budget --account-id 111122223333 --new-budget file://new-budget.json

new-budget.json:

{ "BudgetLimit": { "Amount": "100", "Unit": "USD" }, "BudgetName": "Example Budget", "BudgetType": "COST", "CostFilters": { "AZ" : [ "us-east-1" ] }, "CostTypes": { "IncludeCredit": false, "IncludeDiscount": true, "IncludeOtherSubscription": true, "IncludeRecurring": true, "IncludeRefund": true, "IncludeSubscription": true, "IncludeSupport": true, "IncludeTax": true, "IncludeUpfront": true, "UseBlended": false, "UseAmortized": true }, "TimePeriod": { "Start": 1477958399, "End": 3706473600 }, "TimeUnit": "MONTHLY" }

Il seguente esempio di codice mostra come utilizzareupdate-notification.

AWS CLI

Come sostituire una notifica per un budget di costi e utilizzo

Questo esempio sostituisce una notifica dell’80% per un budget di costi e utilizzo con una notifica del 90%.

Comando:

aws budgets update-notification --account-id 111122223333 --budget-name "Example Budget" --old-notification NotificationType=ACTUAL,ComparisonOperator=GREATER_THAN,Threshold=80,ThresholdType=PERCENTAGE --new-notification NotificationType=ACTUAL,ComparisonOperator=GREATER_THAN,Threshold=90,ThresholdType=PERCENTAGE

Il seguente esempio di codice mostra come utilizzareupdate-subscriber.

AWS CLI

Come sostituire un abbonato con un budget di costi e utilizzo

Questo esempio sostituisce l’abbonato con un budget di costi e utilizzo.

Comando:

aws budgets update-subscriber --account-id 111122223333 --budget-name "Example Budget" --notification NotificationType=ACTUAL,ComparisonOperator=GREATER_THAN,Threshold=80,ThresholdType=PERCENTAGE --old-subscriber SubscriptionType=EMAIL,Address=example@example.com --new-subscriber SubscriptionType=EMAIL,Address=example2@example.com