forked from iandees/aws-billing-to-slack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
51 lines (44 loc) · 1.33 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
service: aws-billing-to-slack
plugins:
- serverless-python-requirements
package:
exclude:
- node_modules/**
- venv/**
provider:
name: aws
# Sane defaults, easy for multi-account/multi-region organizations
profile: ${param:aws_profile, env:AWS_PROFILE, 'default'}
region: ${env:AWS_REGION, env:AWS_DEFAULT_REGION, 'us-east-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:
report_cost:
handler: handler.lambda_handler
description: Send account daily billing data to Slack/Teams
# Keep costs minimal
memorySize: 128
timeout: 10
events:
# Every day at 15:00 UTC / 10am CDT
- schedule: cron(0 15 * * ? *)
environment:
GROUP_BY: ${param:group, 'SERVICE'}
LENGTH: ${param:group_length, 10}
SLACK_WEBHOOK_URL: ${param:slack_url, ''}
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, ''}