-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-budget.py
More file actions
49 lines (46 loc) · 1.74 KB
/
create-budget.py
File metadata and controls
49 lines (46 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import boto3
import csv
from datetime import datetime
client = boto3.client('budgets')
def create_budget_from_csv():
with open('Budget-Template.csv', 'r') as csvfile:
datareader = csv.DictReader(csvfile)
for row in datareader:
response = client.create_budget(
AccountId='XXXX',
Budget={
'BudgetName': row['BudgetName'],
'BudgetLimit': {
'Amount': row['BudgetAmount'],
'Unit': row['Currency']
},
'CostFilters': {
'Service': [row['Filteredby']],
},
'TimeUnit': row['TimeUnit'],
'TimePeriod': {
'Start': row['BudgetStart'],
'End': row['BudgetEnd']
},
'BudgetType': row['BudgetType'],
'LastUpdatedTime': row['CreatedDt'],
},
NotificationsWithSubscribers=[
{
'Notification': {
'NotificationType': 'ACTUAL',
'ComparisonOperator': 'GREATER_THAN',
'Threshold': 80,
'ThresholdType': 'PERCENTAGE'
},
'Subscribers': [
{
'SubscriptionType': row['NotificationType'],
'Address': row['NotificationEmail']
},
]
},
]
)
create_budget_from_csv()
print('check your budget in console')