How to Receive AWS Billing Reports on a Slack Channel

Author:vanus 2023-04-17 17:13:13 139 0 0

As a developer or company, have you ever felt the need to have just another simpler way of monitoring your AWS Billings aside from Email notifications? Well, in this article, I will show you how it is easy to use Vanus and two connectors (AWS Billing Source & Slack Sink) to receive your AWS Billing reports on a Slack channel. This is made possible using Vanus Connect.

Vanus Connect is a set of producers and consumers to provide interoperability across services, systems, and platforms.

img/img_1.png

Vanus Connect has two kinds of connectors; Source connector and Sink Connector. The Source Connector obtains data from an underlying data producer (e.g. AWS Billing) and delivers the data to its target after the data has been transformed into CloudEvents. The Sink Connector receives the events with CloudEvent formats, processes the events, and sends them downstream to a consumer(e.g. Slack)

AWS Billing Source

The AWS Billing Source Connector uses AWS Cost Explorer API to pull billing data from the previous day. The AWS Billing source requires a “target URL” to which it will send the CloudEvents. In this demo, we will be using Vanus Gateway to receive these CloudEvents. You will also need programmatic access credentials (access_key_id & secret_access_key) from your AWS account.

Slack Sink

The Slack sink connector handles incoming CloudEvents in a way that extracts the data part of the original event and delivers these extracted data to Slack channels. To set up Slack sink correctly, you need to create a Slack App and the app should have chat:write and chat:write.public permission

Setting Up AWS Billing Source & Slack Sink using Vanus Connect

In this demo, we will be using the Vanus Playground; A cloud Kubernetes environment. We will create the Slack sink connector first to receive incoming CloudEvents before setting up the AWS Billing Source connector.

To begin, we will install Vanus with the command:

kubectl apply -f https://vanus.s3.us-west-2.amazonaws.com/releases/v0.6.0/vanus.yaml

Confirm that you have it installed:

kubectl get po -n vanus

You should see something like this:

vanus-controller-0               1/1     Running   0          96s vanus-controller-1               1/1     Running   0          72s vanus-controller-2               1/1     Running   0          69s vanus-gateway-8677fc868f-rmjt9   1/1     Running   0          97s vanus-store-0                    1/1     Running   0          96s vanus-store-1                    1/1     Running   0          68s vanus-store-2                    1/1     Running   0          68s vanus-timer-5cd59c5bf-hmprp      1/1     Running   0          97s vanus-timer-5cd59c5bf-pqkd5      1/1     Running   0          97s vanus-trigger-7685d6cc69-8jgsl   1/1     Running   0          97s

Next, we will install vsctl, the command line tool for Vanus

curl -O https://download.linkall.com/vsctl/latest/linux-amd64/vsctl chmod ug+x vsctl mv vsctl /usr/local/bin

Vsctl needs a gateway URL to communicate with Vanus. Get the URL from the service called vanus-gateway. To do this, we have to export the IP address as an Environmental Variable

export VANUS_GATEWAY=192.168.49.2:30001

Setting Up Slack Sink

Now, let’s create a directory for our Slack Sink. To do this, use

mkdir slack

Our directory name is called slack, you can call it what you want. Next, we will move to that directory and create our config.yml file

cd slack

img/img_2.png

Inside the slack directory, create a file called config.yml

touch config.yml

img/img_3.png

To set up Slack sink, we will need to set up our Slack App first and obtain the necessary credentials to receive our Billing report. To set up our Slack App, we will follow these steps:

Create a slack channel where you want to receive the billing Create Slack App. The App should have at least chat:write and chat:write.public permission Create an App from scratch Select the App name and Slack Workspace Add permissions; chat:write and chat:write.public Install OAuth tokens to your workspace Copy the token which we will use in our config.yml file

Now, open the file with your text editor, for this, I will be using vim text editor vi config.yml and paste the following code. Ensure you replace the default, app_name, default_channel, and token with yours.

https://www.vanus.ai/blog/how-to-receive-aws-billing-reports-on-a-slack-channel/

Comments   Please sign in or sign up to post.

0

0 of 500 characters used

Copyright:@2020-2021