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-budgetseguente crea un budget di utilizzo e costi.aws budgets create-budget \ --account-id111122223333\ --budgetfile://budget.json\ --notifications-with-subscribersfile://notifications-with-subscribers.jsonContenuto 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" } ] } ]-
Per i dettagli sull'API, consulta CreateBudget AWS CLI
Command Reference.
-
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-id111122223333--budget-name"Example Budget"--notificationNotificationType=ACTUAL,ComparisonOperator=GREATER_THAN,Threshold=80,ThresholdType=PERCENTAGE--subscriberSubscriptionType=EMAIL,Address=example@example.com-
Per i dettagli sull'API, consulta CreateNotification AWS CLI
Command Reference.
-
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-id111122223333--budget-name"Example Budget"--notificationNotificationType=ACTUAL,ComparisonOperator=GREATER_THAN,Threshold=80,ThresholdType=PERCENTAGE--subscriberSubscriptionType=EMAIL,Address=example@example.com-
Per i dettagli sull'API, consulta CreateSubscriber AWS CLI
Command Reference.
-
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-id111122223333--budget-name"Example Budget"-
Per i dettagli sull'API, consulta DeleteBudget AWS CLI
Command Reference.
-
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-id111122223333--budget-name"Example Budget"--notificationNotificationType=ACTUAL,ComparisonOperator=GREATER_THAN,Threshold=80,ThresholdType=PERCENTAGE-
Per i dettagli sull'API, consulta DeleteNotification AWS CLI
Command Reference.
-
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-id111122223333--budget-name"Example Budget"--notificationNotificationType=ACTUAL,ComparisonOperator=GREATER_THAN,Threshold=80,ThresholdType=PERCENTAGE--subscriberSubscriptionType=EMAIL,Address=example@example.com-
Per i dettagli sull'API, consulta DeleteSubscriber AWS CLI
Command Reference.
-
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-id111122223333--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" ] } } }-
Per i dettagli sull'API, consulta DescribeBudget AWS CLI
Command Reference.
-
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-id111122223333--max-results20Output:
{ "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" ] } } ] }-
Per i dettagli sull'API, consulta DescribeBudgets AWS CLI
Command Reference.
-
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-id111122223333--budget-name"Example Budget"--max-results5Output:
{ "Notifications": [ { "Threshold": 80.0, "ComparisonOperator": "GREATER_THAN", "NotificationType": "ACTUAL" } ] }-
Per i dettagli sull'API, consulta DescribeNotificationsForBudget AWS CLI
Command Reference.
-
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-id111122223333--budget-name"Example Budget"--notificationNotificationType=ACTUAL,ComparisonOperator=GREATER_THAN,Threshold=80,ThresholdType=PERCENTAGE--max-results5Output:
{ "Subscribers": [ { "SubscriptionType": "EMAIL", "Address": "example2@example.com" }, { "SubscriptionType": "EMAIL", "Address": "example@example.com" } ] }-
Per i dettagli sull'API, consulta DescribeSubscribersForNotification AWS CLI
Command Reference.
-
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-id111122223333--new-budgetfile://new-budget.jsonnew-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" }-
Per i dettagli sull'API, consulta UpdateBudget AWS CLI
Command Reference.
-
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-id111122223333--budget-name"Example Budget"--old-notificationNotificationType=ACTUAL,ComparisonOperator=GREATER_THAN,Threshold=80,ThresholdType=PERCENTAGE--new-notificationNotificationType=ACTUAL,ComparisonOperator=GREATER_THAN,Threshold=90,ThresholdType=PERCENTAGE-
Per i dettagli sull'API, consulta UpdateNotification AWS CLI
Command Reference.
-
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-id111122223333--budget-name"Example Budget"--notificationNotificationType=ACTUAL,ComparisonOperator=GREATER_THAN,Threshold=80,ThresholdType=PERCENTAGE--old-subscriberSubscriptionType=EMAIL,Address=example@example.com--new-subscriberSubscriptionType=EMAIL,Address=example2@example.com-
Per i dettagli sull'API, consulta UpdateSubscriber AWS CLI
Command Reference.
-