Skip to content

Slack slash command or Slack bot for control AWS resource via Lambda Function

Notifications You must be signed in to change notification settings

akawork/slack-lambda-functions

 
 

Repository files navigation

Slack integration with AWS Lambda Function

Build an Slack bot can use for manage Instances or Service on AWS

Contents

Features

1. Slash command

  • Basic Actions with an Instance

    • Turn-on
    • Turn-off
    • Get status
    • Get all tag of RDS and EC2 instances
    • Set schedule for turn-on and turn-off instance
    • Approval for turn-on and turn-off instance
  • Actions with a System have same name convention

    • Turn-on
    • Turn-off
    • Get status
    • Approval for turn-on and turn-off system
    • Set schedule for turn-on and turn-off system
    • Receive alert when abnormal action
  • Get detail monitoring information

2. Slack bot

  • Basic Actions with an Instance

    • Turn-on
    • Turn-off
    • Get status
    • Set schedule for turn-on and turn-off instance
    • Approval for turn-on and turn-off instance
  • Actions with a System have same name convention

    • Turn-on
    • Turn-off
    • Get status
    • Approval for turn-on and turn-off system
    • Set schedule for turn-on and turn-off system
    • Receive alert when abnormal action
  • Get detail monitoring information

Create Slack App

Login to your workspace on Slack and go to https://api.slack.com. In this page, click to button Start Building to start create new Slack App.

You will see an pop-up like below:

popup-create-slack-app

Input the App Name and select the Workspace you will use the Slack App. After that, click Create App button

Configure AWS intergrate with Slack Bot

  • In app management page, Select Slash Commands in left menu and click Create Slash command

slash command

  • You will see as below image:

create new slash command

  • Input the command like below image:

input information slash command

  • The result after create like below:

result create slash

Install App to Workspace

  • In API page click Install App in left menu and click to button Install App to Workspace

install app

  • Click Install button to install app to workspace

confirm install app

  • After that you will see as below:

install success app

Create Lambda Functions

  • On Lambda page, click Create function

create lambda page

  • The page will display as below, you must create an role for lambda function

create lambda

  • After create successful you will see the result as below:

create lambda result

Create API via API Gateway

  • In API Gateway page click to Create API button

create api page

  • Input infomation for API and click Create API button

create api

  • Create method for API by click Create Method button as image below

create api method

  • Select POST method

create post method

  • You will see result as below

create method api result

  • You can also can see result in the Design block from Lambda like below

lambda design

Config aws Lambda Functions to use Confirmation feature

  • Copy webhook value of Slack channel that you want to make it become Confirmation channel get slack channel webhook

  • Place this webhook value to SLACK_APPROVAL_ROOM_WEEBHOOK constant in constants.py file (Aws-Lambda Functions)

Develop functions

Requirement

  • Python 3.6
  • AWS CLI

About

Slack slash command or Slack bot for control AWS resource via Lambda Function

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%