Comment out these lines if you don't want to use SES
def send_email(subject,body):
ses_client=boto3.client("ses")
ses_client.send_email(Source='sender@xyz.com',Destination={'ToAddresses': ['recipient@xyz.com']},
Message={
'Subject': {
'Data': subject
},
'Body': {
'Text': {
'Data': body
}
}
}
)
and
send_email("Security Group Notification","Revoked public access to port "+str(ip['FromPort']) +" for security group "+security_group_id)
and
send_email("Security Group Notification","Revoked public access to all ports for security group "+security_group_id)
You can use CloudWatch events to trigger this lambda every 30 minutes