Slack command provides Business unit wise AWS costs based on tags
-
This is to get the cost usage of aws resources (from all accounts) per business unit wise, for the given date range. (Default date will be the previous month, if no custom date provided in the input on slash command.)
-
This is integrated with slack slash command, ie we can issue the command from slack from any channel and get the report immediately on the same slack channel.
- Account on aws.
- serverless framework installed on the system.
- Account on serverless.
-
Install the serverless framework cli with the below command.
npm install -g serverless
-
Verify that Serverless is installed with the below command.
serverless --version
orsls --version
-
Log into serverless portal with the below command which will open the portal in the browser.
sls login
-
We are using the below two serverless plugins which needs to be installed on the system before the deployment.
- serverless-prune-plugin
- serverless-python-requirements
-
Command to install these plugins.
sls plugin install -n serverless-prune-plugin
sls plugin install -n serverless-python-requirements
-
Run the below command from the directory where the 'serverless.yaml' present which will have the details of the function.
sls deploy
- Configure
slack_web_hook
,slack_user_name
, slacktoken
andslack_default_channel
- Configure
tag_name
that marks different business units.
-
We can verify the deployment using follwing command.
sls deploy list functions
-
Output should show aws-cost-usage in list with the Version details.
-
Run the below command for more details of the deployed function.
sls info
-
Output will have details of the service name, function name, endpoint and the stage of the deployment.
-
Run the below command to invoke the function.
sls invoke -f aws-cost-usage
-
Update on serverless.yaml and before deployment, run the below local invoke command to test.
sls local invoke -f aws-cost-usage
-
function logs
sls logs -f <function name>
sls logs -f aws-cost-usage
-
Run the below command from slack fron any channel to get the report.
/cost
- AWS Cost will be generated on the same channel for the previous month./cost aws
- AWS Cost will be generated on the same channel for the previous month./cost aws start_date end_date
(date format: yyyy-mm-dd): Report generated for the given custom dates.
- Login to serverless portal
- We can view the deployed functions inside the prognos tenant and deployed details can be be viewed for the deployed functions.
-
We can invoke the function using local variables as below.
serverless invoke local -f aws-cost-usage -e slack_default_channel="#devnull"
- For any issues or changes please contact @ankurpshah