Windows service alternative in AWS Cloud
Windows service alternative in AWS Cloud
Scenario
We were having a requirement of sending report as PDF in an email attachment on scheduled basis. In a previous system before migrating it to AWS Cloud, it was handled using the .Net Windows service with complete logic inside the service only.
Implemented approach
AWS Services utilized
- AWS Lambda Function – C#.Net
- Cloud Watch Events – Trigger
How it is implemented
Moved the logic to Web API
Logic to generate the report is moved to Web API route, each report has its own route which give desire result.
AWS Lambda function become as middleware
AWS Lambda function is now responsible for two tasks.
- Get the report from Web API based on the input parameter from the trigger
- Send email to the respective subscription list
AWS Lambda function get only one input as report name which must be generate and send it across. Lambda function contains switch statement and respective function for each report to get from Web API and one generic function which sends an email.
Cloud watch events is a trigger point to AWS Lambda function
Finally, Cloud watch events is main stuff which trigger the AWS Lambda function based on the configured schedule. Here we used the Cron expression to schedule a job on specific time.
AWS approach design diagram