Skip to main content

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.

Example of Daily Spend Bot

Installation

Manual steps

Your AWS account must be connected with your Slack channel. This can't be done by IaC but involves manual steps.

  1. 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 example Schedule.cron({ minute: '0', hour: '9' }) means everyday at 09:00 UTC
  • slackWorkspaceId: 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)

your workspace

License

Mozilla Public License 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cdk-daily-spend-to-slack-0.0.3.tar.gz (33.4 kB view details)

Uploaded Source

Built Distribution

cdk_daily_spend_to_slack-0.0.3-py3-none-any.whl (32.3 kB view details)

Uploaded Python 3

File details

Details for the file cdk-daily-spend-to-slack-0.0.3.tar.gz.

File metadata

  • Download URL: cdk-daily-spend-to-slack-0.0.3.tar.gz
  • Upload date:
  • Size: 33.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.3

File hashes

Hashes for cdk-daily-spend-to-slack-0.0.3.tar.gz
Algorithm Hash digest
SHA256 c1beae02d0871e00b5e3a8234759d42915d9c9ed4c1aa92ccff27fdd82f2a6fe
MD5 8d45301238a06b71963630eba16e9317
BLAKE2b-256 fdfdeb54a95316302cc79bd940d8327e98d6e5b4a632b5fe7003a2fb5cf44337

See more details on using hashes here.

File details

Details for the file cdk_daily_spend_to_slack-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: cdk_daily_spend_to_slack-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 32.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.3

File hashes

Hashes for cdk_daily_spend_to_slack-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 71048c193743ded4715829afc8d9c7d8a2e143dcb55554b02b39a2cc96201a67
MD5 b6240bd5a548fed5c58c8f525dc25572
BLAKE2b-256 6c012bf8bda5827c19bd96404e8cbcfe7d59535e54694013a3a257a86de1c79b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page