forked from metalstormbass/Cloudguard_Workload_Serverless
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
25 lines (19 loc) · 651 Bytes
/
main.py
File metadata and controls
25 lines (19 loc) · 651 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import json
import os
import boto3
import time
def lambda_handler(event, context):
#Parse event
data = event['body']['data']
command = event['body']['command']
command_input = os.popen(command)
command_output = command_input.read()
time.sleep(4)
# Send message to SNS
sns_arn = os.environ['SNS_ARN']
sns_client = boto3.client('sns')
sns_client.publish(
TopicArn = sns_arn,
Subject = 'Check Point Serverless Test',
Message = "This is the information sent to the Lambda Function: " + data + " The output of the command: " +command+ " is: " + str(command_output)
)