forked from codetalkio/aws-billing-to-slack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
52 lines (44 loc) · 1.48 KB
/
serverless.yml
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
50
51
52
service: aws-billing-to-slack
provider:
name: aws
profile: ${param:aws_profile, env:AWS_PROFILE, 'default'}
region: ${env:AWS_REGION, env:AWS_DEFAULT_REGION, 'eu-central-1'}
runtime: python3.10
iam:
role:
statements:
- Effect: "Allow"
Action:
- "ce:GetCostAndUsage"
Resource: "*"
# Needed to get account alias.
- Effect: "Allow"
Action:
- "iam:ListAccountAliases"
Resource: "*"
functions:
reportCostToSlack:
handler: handler.lambda_handler
description: Send account daily billing data to Slack
# Keep costs minimal.
memorySize: 128
timeout: 10
events:
# Every day at 07:00 UTC.
- schedule: cron(0 07 * * ? *)
environment:
GROUP_BY: ${param:group, 'SERVICE'}
LENGTH: ${param:group_length, 10}
SLACK_WEBHOOK_URL: ${param:slack_url, ''}
DAILY_BUDGET: ${param:daily_budget, ''}
DAILY_BUDGET_WEEKDAY: ${param:daily_budget_weekday, ''}
DAILY_BUDGET_WEEKEND: ${param:daily_budget_weekend, ''}
TEAMS_WEBHOOK_URL: ${param:teams_url, ''}
AWS_ACCOUNT_NAME: ${param:aws_account, ''}
CREDITS_EXPIRE_DATE: ${param:credits_expire_date, ''}
CREDITS_REMAINING_AS_OF: ${param:credits_remaining_date, ''}
CREDITS_REMAINING: ${param:credits_remaining, ''}
COST_AGGREGATION: ${param:cost_aggregation, 'AmortizedCost'}
ACCOUNTS: ${param:accounts, ''}
plugins:
- serverless-python-requirements