daily-spend-to-slack
Project description
Daily spend to slack
A construct that deploys a CloudWatch cronjob that will trigger a Lambda that will fetch the yesterday usage of AWS and send it to a SNS as a spoofed ECR CloudWatch event that can be parsed by AWS Chatbot and send to Slack.
Yes, that was a mouthful. But the general idea is that to create a FinOps/Cost optimization culture in your team, your team also needs to know what they are spending. That is why I created this. This construct will deliver the yesterday usage to your slack channel of choice. This can also be a private channel.
Installation
Manual steps
Your AWS account must be connected with your Slack channel. This can't be done by IaC but involves manual steps.
- Follow the steps of Step 1 in the category "Setting up AWS Chatbot with Slack"
CDK steps
# Example automatically generated from non-compiling source. May contain errors.
'use strict';
import { App, Stack } from 'aws-cdk-lib';
import { Schedule } from 'aws-cdk-lib/aws-events';
import { DailySpendToSlack } from './index';
const app = new App();
const stack = new Stack(app, 'DailySpendToSlack');
new DailySpendToSlack(stack, 'DailySpendToSlack', {
schedule: Schedule.cron({ minute: '0', hour: '9' }),
slackWorkspaceId: '',
slackChannelId: '',
slackChannelName: '',
accountName: 'stroobants.dev',
});
Parameters
schedule
: Schedule - The schedule it should run on, for exampleSchedule.cron({ minute: '0', hour: '9' })
means everyday at 09:00 UTCslackWorkspaceId
: string - The ID that AWS generates for (see picture below)slackChannelId
: string - The ID of the Slack Channel (Open slack, right-click on the channel you want the bot in, Copy link) ->https://cloudar.slack.com/archives/{slackChannelId}
)slackChannelName
: string - The name of the Slack channel (this will be used to generate the Configuration name)accountName
: string - You can give the bot a recognizable name, lowercase, max 30 and only.-
allowed (could be more but that is what I tested)
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for cdk-daily-spend-to-slack-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50e4bc43908a47af2ae5f085896f20b95c1731f924027e36358b9cf063fb507d |
|
MD5 | f52e607b759eb19089d507a724ed4519 |
|
BLAKE2b-256 | 5a78ea9f6e48d65aab7d685b65070ca71302ac02f873d19f0c3a63fa71aadcc6 |
Hashes for cdk_daily_spend_to_slack-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6aa9f432e345080e186a6d4569f254fd22ba22a599c61e88843a93baa94211a5 |
|
MD5 | 2951dfb550176fe76ad0779e302f447d |
|
BLAKE2b-256 | 1ac042edc513795e7bd3921905e4f534f9d138e1f51c2ca987f3a3aab3445922 |