Giter Site home page Giter Site logo

y0zg / aws-billing-to-slack Goto Github PK

View Code? Open in Web Editor NEW

This project forked from iandees/aws-billing-to-slack

0.0 0.0 0.0 462 KB

Send a daily AWS cost report to a Slack channel of your choice.

License: MIT License

Python 98.21% Dockerfile 1.79%

aws-billing-to-slack's Introduction

AWS Billing to Slack

image

Sends daily breakdowns of AWS costs to a Slack channel.

Install

  1. Install serverless, which I use to configure the AWS Lambda function that runs daily.

    npm install -g serverless
    
  2. Create an incoming webhook that will post to the channel of your choice on your Slack workspace. Grab the URL for use in the next step.

  3. Create the service on your local machine. cd to your directory and run this command. Replace path with the path name for the service and app name for the service.

    serverless create \
      --template-url="https://github.com/iandees/aws-billing-to-slack.git" \
      --path="app-aws-cost" \
      --name="app-aws-cost"
    
  4. Install pipenv

    pip install pipenv==2023.7.4
    
  5. Install serverless python requirements

    serverless plugin install -n serverless-python-requirements
    
  6. Deploy the system into your AWS account, replacing the webhook URL below with the one you generated above.

    serverless deploy --stage="prod" --param="slack_url=https://hooks.slack.com/services/xxx/yyy/zzzz"
    

    You can also run it once to verify that it works:

    serverless invoke --function report_cost --stage="prod" --param="slack_url=https://hooks.slack.com/services/xxx/yyy/zzzz"
    

Support for AWS Credits

If you have AWS credits on your account and want to see them taken into account on this report, head to your billing dashboard and note down the "Expiration Date", "Amount Remaining", and the "as of" date towards the bottom of the page. Add all three of these items to the command line when executing the deploy or invoke:

```
serverless deploy \
    --param "slack_url=https://hooks.slack.com/services/xxx/yyy/zzzz" \
    --param "credits_expire_date=mm/dd/yyyy" \
    --param "credits_remaining_date=mm/dd/yyyy" \
    --param "credits_remaining=xxx.xx"
```

Support for other Dimensions

If you have and AWS Organisation established and would like to see a breakdown by account, you can override the default dimensions with parameters:

```
serverless deploy \
    --param "slack_url=https://hooks.slack.com/services/xxx/yyy/zzzz" \
    --param "group=LINKED_ACCOUNT" \
    --param "group_length=15"
```

Possible value for group are:

  • AZ
  • INSTANCE_TYPE
  • LINKED_ACCOUNT
  • OPERATION
  • PURCHASE_TYPE
  • SERVICE
  • USAGE_TYPE
  • PLATFORM
  • TENANCY
  • RECORD_TYPE
  • LEGAL_ENTITY_NAME
  • INVOICING_ENTITY
  • DEPLOYMENT_OPTION
  • DATABASE_ENGINE
  • CACHE_ENGINE
  • INSTANCE_TYPE_FAMILY
  • REGION, BILLING_ENTITY
  • RESERVATION_ID
  • SAVINGS_PLANS_TYPE
  • SAVINGS_PLAN_ARN
  • OPERATING_SYSTEM

Other Useful CLI Arguments Related to your AWS account

By default, AWS_PROFILE and AWS_REGION are defaulting to default and us-east-1. These value can be changed by modifying the environment. For aws account, sensible default is attempted to be retrieved. For example, boto3 is used to try and determine your AWS account alias if it exists, and if not your AWS account ID. Additionally, for your AWS region the environment variables AWS_REGION, then AWS_DEFAULT_REGION are read and used if present, otherwise fallback to 'us-east-1' (N. Virginia).

```
AWS_PROFILE="default" AWS_REGION="eu-west-1" serverless deploy \
    --param "slack_url=https://hooks.slack.com/services/xxx/yyy/zzzz" \
    --param "aws_account=my custom account name"
```

Support for different cost aggretations

By default we show the unblended costs, but if you set the environment variable COST_AGGREGATION to something else, you can change the cost aggretation AWS uses. Possible values are: AmortizedCost, BlendedCost, NetAmortizedCost, NetUnblendedCost, NormalizedUsageAmount, UnblendedCost, and UsageQuantity. More information is available at the Metrics request parameter here

Authors

aws-billing-to-slack's People

Contributors

iandees avatar dependabot[bot] avatar alex-ley avatar rwilson-release avatar marledk avatar hassan-cevo avatar ruiseek avatar stevemac007 avatar ohe avatar cibinmathew avatar colin-l2w avatar danielamiao avatar estahn avatar tamasflamich avatar ma-supsys avatar manujo-varghese avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.