Get your AWS billing info in Slack with Nimbella Commander

Mar 12, 2020 | Commander

copied

Have you ever wanted a simple way of displaying your AWS billing info on Slack? With Nimbella Commander, you can have your current bill or a bill from any other month displayed in one command to your Slack workspace. This conveniently integrated AWS billing functionality will allow developers to have cost-visibility without having to navigate complex billing systems, which will benefit the entire organization in the long run.

aws bill in slack result with month and year

Later, I’ll show you how to restrict who can access this Slack command so it’s only available to people who need to know.

In just 7 simple steps, we will install Commander into Slack, add the API keys to Commander, and run the commands to show your AWS bill. If you don’t have any API keys set up in your AWS account, then you can scroll down to the section titled “Creating test API Keys for Commander”. But if you already have API Keys ready, then you can start at the section titled “Install Commander into Slack”.

Install Commander into Slack:

  1. Add Nimbella Commander to your Slack Team. You can add it by searching “Nimbella” in the apps tab on Slack. You can also add it by going to our official website and clicking the “Add to Slack” button.

commander inside Slack to help display aws billing info in slack

  1. In order to get your AWS billing details, you’ll need to install the billing Command Set. Command Sets are a packaging specification for Slack commands, and a convenient way to share commands via GitHub or open source. Command Sets are installed into your Slack teams via the Nimbella Commander by typing the command /nc csm_install billing in your Slack prompt.

billing command to display aws billing info in slack

Applying your API Keys:

  1. Next, we need to bind some secrets to the billing commands. Specifically, the AWS API keys you generated earlier for the AWS API will be encrypted (outside of Slack) and attached to the slash command. To do this, type /nc secret_create to bring up the Nimbella Secret Creator. We’re creating the secrets outside of Slack so that Slack will only see encrypted strings and not your API keys. When you run the secrets command, you will see an output that looks like this:

Secret Creator to create encrypted api keys to display aws billing info in slack

  1. Click on the Secret Creator link to be redirected to the page which encrypts your API keys.

encrypt AWS api keys to help display aws billing info in Slack

  1. Add your AWS keys to the fields in the Secret Creator as illustrated in the following figure. Next, click the “Make Secrets” button to generate the commands you’ll need to copy and paste into your Slack prompt.

commander secret creator to encrypt api keys for aws billing info in slack

  1. After clicking the “Make Secrets” button, the commands you’ll need to run on your Slack page will appear. Copy each command one at a time and paste them into Slack (using Clipboard copy). This will take your AWS Cost Explorer keys and apply them.

secret creator to encrypt AWS api keys to display aws billing info in slack

commands to encrypt aws api keys to display aws billing information in slack

Run the billing Command Set in Slack:

  1. Finally, run the built-in command /dapp awsbill to see your AWS billing info.

aws billing info in slack being displayed with Commander in Slack

  1. To see a particular month bill, try /dapp awsbill MM/YYYY

aws billing info in slack being displayed with Commander in Slack

  1. You likely don’t want everyone in your Slack team to run this command. Nimbella Commander offers a neat feature to allow only certain users to run specific commands. For example, you can restrict access to the AWS billing command to specific users using** **/nc command_runners awsbill+ @user1 + @user2, substituting for “user1” and “user2” the Slack names of your teammates that should have access to the AWS billing details.

command to run in Slack to display AWS billing information in Slack

  1. It’s worth also mentioning that you have access to an audit trail to see who’s run your commands. This is useful for administrators and team oversight where appropriate. Type /nc command_log awsbill

audit log of users who ran aws billing info in slack

  1. One last thing that’s important to know is that the code for the awsbill command you import into Commander is yours to edit. If you type /nc command_code awsbill, you will receive a secure link that will allow you to edit the command.

command to edit code that can display aws billing info in slack

Using Nimbella’s access control you can also limit who can view and edit the code that implements a particular command as well. The built-in Secret Creator means your sensitive data remains outside of Slack and accessible only to the code you run. And with Audit Logs, you have accountability and historical data readily available at your fingertips. These are powerful features of the Commander that don’t exist in Slack otherwise. For more information about Commander, visit our website. We’d also love to hear from you via our community Slack channel or on GitHub.

If you wish to add Commander to your Slack account, click this link to get started today!

Test API Keys:

Important note: If you’ve not enabled Cost Explorer, you’ll have to wait 24 hours once you enable it. But if you have AWS account enabled for Cost Explorer, you don’t need to do this.

24 hour wait.

  1. Go to IAM in AWS services (AWS Management Console)

aws access management page IAM to help display aws billing info in slack

  1. In the Access Management tab on the left. Click “Policies” and select the “Create a policy” button.

create policy in AWS access management AIM to set up AWS billing info being displayed in Slack

  1. On the Create Policy page. Click “service” and search ”Cost Explorer Service”. In “Actions”, select the “Read” and “list” boxes.

policy creation to help display AWS billing info in Slack

  1. On the “Review policy” page, name it “CostExplorerReadOnly” and click “Create Policy”.

creating policy in AWS AIM to display AWS billing info in Slack

  1. On the IAM page, click the Groups tab and select the “Create New Group” button.

Create group in AWS AIM to display AWS billing info in Slack

  1. Create a group name and call it “CostExplorerGroup”.

Set group in AWS AIM to display AWS billing info in Slack

  1. Attach the policy you created by typing “CostExplorerReadOnly” in the pages search bar and select it. “Click the “next step” button at the bottom right of the screen after selecting it. The last step in creating a new group is just a review. Click “Create Group” once you’re at Step 3.

Attach policy in AWS AIM to display AWS billing info in Slack

  1. Go to the IAM tab and select the user’s tab. Then click the “Add User” button.

create user in AWS IAM to display AWS billing info in Slack

  1. Add the user and call it “CostExplorerAPIOnly”. Select programmatic access.

user creation in AWS IAM to display AWS billing info in Slack

  1. Select “CostExplorerReadOnly” on this page.

user creation in AWS IAM to display AWS billing info in Slack

  1. Ignore the "add tags" section. It’s optional. Click the “Next: Review” button at the bottom right of the screen.

adding user in AWS IAM to display AWS billing info in Slack

  1. Click the“Create user” button at the bottom right of this page.

aws user in IAM to display AWS billing info in Slack

  1. After clicking the “Create user” button. You’ll be directed to a page that will have your Access Key ID and Secret Access Key. You will need both of these API keys to use the AWS functionality in Slack. So keep this page open when you go to your Slack page.

added user in AWS IAM to display AWS billing info in Slack


Recent Posts