Skip to content

nikosheng/alibaba-dingding-lambda-layer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alibaba-dingding-lambda-layer-sam

Deploy in Serverless Application Repository

  • Login AWS Console and navigate to Serverless Application Repository service.
  • Search alibaba-dingding-lambda-layer in Available Applications
  • Press Deploy button to deploy the lambda layer to your account
  • Navigate to Lambda service and find out the layer is already deployed or not

Usage

Please configure the Ali Dingding Robot to invoke the alarm message, for more information about the configuration, please refer to LINK

使用阿里钉钉告警需要提前配置自定义机器人,具体可以参考阿里官方文档

Please Make Sure to Input Dingding Robot Access Token in Lambda Evironment Variables

使用该Lambda Layer 请务必设置调用Lambda内阿里钉钉机器人Webhook内的Access Token环境变量以调用接口

import json
import os
from layer.dingding import DingRobot
from layer.alarm import Alarm

def hello(event, context):
    token = os.environ['ACCESSTOKEN']
    robot = DingRobot(token)
    dingAlarm = Alarm(
        title = "AWS 告警信息",
        text = "### {0}\n >{1}".format(event['Records'][0]['Sns']['Subject'], event['Records'][0]['Sns']['Message']),
        atMobiles = "",
        isAtAll = True
    )
    body = robot.send_msg(dingAlarm)

    response = {
        "statusCode": 200,
        "body": json.dumps(body)
    }

    return response

Happy Building!
Niko ([email protected])

About

AWS Lambda Layer - Alibaba Dingding Integration

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages