

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
<a name="cli_budgets_code_examples"></a>

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.

**Topics**
+ [Azioni](#actions)

## Azioni
<a name="actions"></a>

### `create-budget`
<a name="budgets_CreateBudget_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`create-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"
            }
        ]
    }
]
```
+  Per i dettagli sull'API, consulta [CreateBudget AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/budgets/create-budget.html)*Command Reference*. 

### `create-notification`
<a name="budgets_CreateNotification_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`create-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
```
+  Per i dettagli sull'API, consulta [CreateNotification AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/budgets/create-notification.html)*Command Reference*. 

### `create-subscriber`
<a name="budgets_CreateSubscriber_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`create-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
```
+  Per i dettagli sull'API, consulta [CreateSubscriber AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/budgets/create-subscriber.html)*Command Reference*. 

### `delete-budget`
<a name="budgets_DeleteBudget_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`delete-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"
```
+  Per i dettagli sull'API, consulta [DeleteBudget AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/budgets/delete-budget.html)*Command Reference*. 

### `delete-notification`
<a name="budgets_DeleteNotification_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`delete-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
```
+  Per i dettagli sull'API, consulta [DeleteNotification AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/budgets/delete-notification.html)*Command Reference*. 

### `delete-subscriber`
<a name="budgets_DeleteSubscriber_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`delete-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
```
+  Per i dettagli sull'API, consulta [DeleteSubscriber AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/budgets/delete-subscriber.html)*Command Reference*. 

### `describe-budget`
<a name="budgets_DescribeBudget_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`describe-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"
           ]
       }
   }
}
```
+  Per i dettagli sull'API, consulta [DescribeBudget AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/budgets/describe-budget.html)*Command Reference*. 

### `describe-budgets`
<a name="budgets_DescribeBudgets_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`describe-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"
               ]
           }
       }
   ]
}
```
+  Per i dettagli sull'API, consulta [DescribeBudgets AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/budgets/describe-budgets.html)*Command Reference*. 

### `describe-notifications-for-budget`
<a name="budgets_DescribeNotificationsForBudget_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`describe-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"
       }
   ]
}
```
+  Per i dettagli sull'API, consulta [DescribeNotificationsForBudget AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/budgets/describe-notifications-for-budget.html)*Command Reference*. 

### `describe-subscribers-for-notification`
<a name="budgets_DescribeSubscribersForNotification_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`describe-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"
       }
   ]
}
```
+  Per i dettagli sull'API, consulta [DescribeSubscribersForNotification AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/budgets/describe-subscribers-for-notification.html)*Command Reference*. 

### `update-budget`
<a name="budgets_UpdateBudget_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`update-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"
 }
```
+  Per i dettagli sull'API, consulta [UpdateBudget AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/budgets/update-budget.html)*Command Reference*. 

### `update-notification`
<a name="budgets_UpdateNotification_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`update-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
```
+  Per i dettagli sull'API, consulta [UpdateNotification AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/budgets/update-notification.html)*Command Reference*. 

### `update-subscriber`
<a name="budgets_UpdateSubscriber_cli_topic"></a>

Il seguente esempio di codice mostra come utilizzare`update-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
```
+  Per i dettagli sull'API, consulta [UpdateSubscriber AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/budgets/update-subscriber.html)*Command Reference*. 