AWS Lambda & Python Project

Job ID: 34206076

Budget: $30 – $250 AUD

Hello, I will need a quote and timeframe for the following python code that I need, thank you!

I will outline what the python code will need to do:

1. Identify any user that has not logged into their AWS Workspace for more than 49 days. This can be done using something like this

LastKnownUserConnectionTimestamp' in workspace_detail['WorkspacesConnectionStatus'][0]:
workspacelastuseddate=workspace_detail['WorkspacesConnectionStatus'][0]['LastKnownUserConnectionTimestamp']
time_difference=datetime.utcnow()-workspacelastuseddate.replace(tzinfo=None)
if (time_difference.total_seconds() / (3600*24)) > 49

Once identified it will need to send an email to the user who owns the workspace using SMTP
https://realpython.com/python-send-email/

That will be the first part of the code, straight forward, find which users who havent logged into their Workspace for more than 49 days and send all of those users an email via SMTP

The next code I will need is to find all users who havent logged into their Workspace for more than 56 days. and delete their AWS Workspace. Next remove that user from an Active Directory security group using something like this
from win32com.client import GetObject

group = GetObject("LDAP://CN=groupname,OU=Groups,DC=blah,DC=local")

group.Remove("LDAP://CN=username,OU=Users,DC=blah,DC=local")
the code will need to use a service account that has access to remove the user from the group. SO will to most likely specify the domain\username and the password of the account that has access to remove the users

lastly after terminating the workspace and removing the user from the AD SG the code should send an email to an IT email address saying that this users workspaceID, Computername, userid has been removed

Something to note is that if the Workspace has one of the following tags the whole process is to be ignored:
Type:Audit
Type:Oncall

This will be a function in AWS Lambda that runs once a day. I believe Layers might need to be used to remove users from the Active Directory Security Group.