Skip to content

Instantly share code, notes, and snippets.

Created May 26, 2022 14:40
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
import json
import os
from botocore.vendored import requests
SLACK_URL = os.environ.get('SLACK_URL')
def create_table(event, context):
formatted = format_message(event)
def format_message(event):
detail = event.get('detail')
parameters = detail.get('requestParameters')
identity = detail.get('userIdentity')
table_name = parameters.get('tableName')
region = detail.get('awsRegion')
username = identity.get('userName')
user_type = identity.get('type')
text = '\n'.join([
"New DynamoDB table created!",
"Table *{}* created in region *{}*".format(table_name, region),
"Request made by username *{}*, a *{}*.".format(username, user_type)
return {
"text": text
def send_to_slack(message, url=SLACK_URL):
resp =, json=message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment