Skip to main content

Posts

Showing posts with the label lambda

Some AWS lambda functions

import json from urllib.request import Request, urlopen def lambda_handler(event, context): #webhookurl webhookurl = "https://hooks.slack.com/services/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" # ec2 detail = event['detail'] instance_id = detail['instance-id'] instance_state = detail['state'] messe = "msg here" if instance_id == "i-000d520e3ec8d6f97" : messe = "STG" elif instance_id == "i-0e2b0157636751cc7" : messe = "sest" elif instance_id == "i-018fcaabe46773e38" : messe = "prod" elif instance_id == "i-06fcd00b94795927c" : messe = "live" elif instance_id == "" : messe = "STG02" # (attachmen if instance_state == "stopped": slack_message = { "attachments": [ { ...