Monitor your Employee Workstation using AWS Free Tier Services
ABC Company asked if we can monitor a specific employee workstation. I know that there are many 3rd party software available in the market which runs silently on user computers and captures the screen to send it to the administrator. However, I don’t wanna go to that route as the employees work on really sensitive code that is private for compliance reasons. I don’t trust the 3rd party services (as nothing comes free in this world 😜 ). So I decided to use AWS Free Tier services ❤️ to solve this use case.
Create API Gateway
Create the API Gateway which will accept the Binary content-type header as Image and save that to S3 Bucket using PUT Method. If you don’t know how to set up API Gateway then click here
Make sure that the role assigned to API Should have the following permissions
- PutObject to S3
- GetObject from S3
- Lambda Execution Role
- Publish to SNS Topic
- TrustPolicy → AWS Lambda, API Gateway (otherwise APIGateway & lambda won’t assume the role)
Create Lambda Function
The next step is to create a Lambda function with a runtime Python3.9, and use the following code in Lambda function
Please change the bucket name and photo name variable with the correct values. Make sure to create the SNS topic and subscribe to your/HR email. (if you don’t know how to set up SNS and click here). In my case, I’m using EmailNotification topic and publishing emails to this topic which is subscribed to my email address. Also, make sure that role attached to Lambda should have permission to Publish to SNS and use Rekognition service (to read the image) as mentioned above in bullet points
On Employee Workstation
That’s pretty much it on AWS side. Now on the employee machine make sure that Python is installed. Schedule the job in ‘Task Scheduler’ in windows to run the following simple code after every 5 minutes. If Linux then set up the corn job to run the python code after every 5 minutes.
import requests
import pyautoguimyScreenshot = pyautogui.screenshot()
myScreenshot.save(r'C:\Users\xxxxxxxx\Downloads\screenshot.jpeg')data = open(r'C:\Users\xxxxxxxx\Downloads\screenshot.jpeg','rb').read()
r = requests.post('https://xxxxxxxxx.execute-api.us-east-1.amazonaws.com/v1/bucket/screenshot.jpeg',data=data)
You might need to install the library pyautogui
pip install pyautogui
use requests method in python to send the image to APIGateway.
Please hit the clap icon 👏 if you like this article. Let me know if you have any other ideas or want me to write an article for some specific case, I will try my best to solve that.
Youtube: https://youtu.be/I3t3xvQzPow