How I automated checking the availability of Covid vaccine centers using AWS Lambda and CloudWatch

sathvik sanagavarapu
4 min readMay 2, 2021

Recently, I was frustrated with repeatedly checking for Covid vaccination centers that would serve citizens of age group below 45 years. I had become curious if this simple, mundane human task can be automated, and I receive an email as soon as they become available. The rest of the article goes as follows:

  1. Finding the appropriate URL end-point using Burp Suite.
  2. Developing a python script to hit URL, process response.
  3. Adding email-sending functionality using AWS SES SDK.
  4. Deploying the script as an AWS Lambda function.
  5. Using AWS CloudWatch to trigger the Lambda function periodically.

1. Using Burp Suite for intercepting the HTTP traffic

Found this fantastic tool called Burp which can be used to intercept and capture HTTP traffic. I used this tool to sneak upon the requests sent from the Cowin website to the backend and identified the HTTP GET URL, giving the desired response.

Fig 1. Intercepted Request
Fig 2. Response for above request

2. Python script to send request and analyze response

Using requests module from the python library, we can hit the above URL and obtain the response. The response can then be processed further by analyzing the JSON object received and scanned for desired fields. In my case, I had been looking for centers, which are providing vaccination for citizens below 45 year age group. The field min_age_limit turned out to be of interest for this particular task.

3. Triggering email using AWS SES

We can use AWS SES utility as your email client to trigger emails from the python script itself. The information extracted in the above step regarding the centers can be packaged into the email body. I have configured the aws_ses_client which lifts most of the overhead related to triggering emails. The code about using AWS SES SDK and remaining code can be found at: Github Repo. Alternatively, you can also use smtplib module which ships with python package itself. You can configure “smtp.google.com” as your outbound server and provide credentials of your own google account. . Google has been very friendly to provide troubleshooting for commonly faced problems already.

4. Deploying the script as AWS Lambda function

AWS Lambda allows you to deploy your python script as a lambda function. To do so, you may log in to your AWS account and navigate to the AWS Lambda dashboard. You then click on Create function and choose python as your instance’s runtime environment. Once the function is created, you may add your script as the code of your function, as shown below. Once you test your Lambda function, you can then deploy it.

Fig 3. Create lambda function
Fig 4. Add code to lambda_function.py

5. Add AWS Lambda function as a target for AWS CloudWatch event

Once the AWS lambda function is deployed, you may add it as a target for a scheduled CloudWatch event. To do so, you may navigate to the AWS CloudWatch dashboard and add a Rule in the “Rules” sub-section of the “Events” section as shown below. The rule comprises of two parts:

  1. When to trigger: For every 1 hour, in my case
  2. What to trigger: Tested and deployed Lambda function.
Fig 5. Periodically schedule lambda function

That’s it; you will receive an email as soon as any covid center in your district opens vaccination for the below 45 age group.

Fig 6. Mails as triggered from lambda function
Fig 7. Mail body containing desired information

Cheers. Thanks for reading. Hope you learnt something new today.

--

--