Skip to content

Commit

Permalink
feat: add cloudformation stack for notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
sbstjn committed Mar 10, 2021
1 parent 2da666d commit cb26300
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions templates/notifications.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31

Resources:
NotificationTopic:
Type: AWS::SNS::Topic

NotificationOpsItemCreated:
Type: AWS::Serverless::Function
Properties:
Events:
Enable:
Type: CloudWatchEvent
Properties:
Pattern:
source:
- aws.ssm
detail-type:
- AWS API Call via CloudTrail
detail:
eventName:
- CreateOpsItem
eventSource:
- ssm.amazonaws.com
Handler: index.handler
Runtime: python3.7
Environment:
Variables:
TOPIC_ARN: !Ref NotificationTopic
InlineCode: !Sub |-
import json
import urllib3
import boto3
import os
client = boto3.client('organizations')
def handler(event, context):
print("received event")
print(event)
print(event['requestParameters']['title'])
print(event['requestParameters']['description'])
print("https://${AWS::Region}.console.aws.amazon.com/systems-manager/opsitems/{}".format(event['responseElements']['opsItemId']))

0 comments on commit cb26300

Please sign in to comment.