Budget AWS esempi utilizzando AWS CLI - AWS Command Line Interface

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 operazioni sono estratti di codice da programmi più grandi e devono essere eseguite nel contesto. Mentre le azioni mostrano come richiamare le singole funzioni di servizio, è possibile visualizzare le azioni nel loro contesto negli scenari correlati.

Ogni esempio include un collegamento al codice sorgente completo, in cui è possibile trovare istruzioni su come configurare ed eseguire il codice nel contesto.

Argomenti

Azioni

Il seguente esempio di codice mostra come utilizzarecreate-budget.

AWS CLI

Per creare un budget di costi e utilizzo

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

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" } ] } ]
  • Per API i dettagli, vedere CreateBudgetin AWS CLI Command Reference.

Il seguente esempio di codice mostra come utilizzarecreate-notification.

AWS CLI

Per creare una notifica per il budget di costo 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

Per creare un sottoscrittore per una notifica associata a un budget di costo e utilizzo

Questo esempio crea un sottoscrittore 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

Per 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"
  • Per API i dettagli, vedere DeleteBudgetin AWS CLI Command Reference.

Il seguente esempio di codice mostra come utilizzaredelete-notification.

AWS CLI

Per eliminare una notifica da un budget

Questo esempio elimina 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

Per eliminare un sottoscrittore da una notifica

Questo esempio elimina il sottoscrittore 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

Per 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" ] } } }
  • Per API i dettagli, vedere DescribeBudgetin AWS CLI Command Reference.

Il seguente esempio di codice mostra come utilizzaredescribe-budgets.

AWS CLI

Per recuperare i budget associati a un account

Questo esempio recupera i budget relativi ai costi e all'utilizzo di 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

Per 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

Per richiamare gli abbonati per una notifica sul budget

Questo esempio recupera gli abbonati per una notifica sul 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

Per 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" }
  • Per i API dettagli, vedere in Command Reference. UpdateBudgetAWS CLI

Il seguente esempio di codice mostra come utilizzareupdate-notification.

AWS CLI

Per 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

Per sostituire un abbonato per un budget relativo ai costi e all'utilizzo

Questo esempio sostituisce il sottoscrittore per 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