cowin-notifier
A Node.js AWS Lambda function to periodically check cowin for empty vaccination slots and send emails with slot details. It's currently configured to suit my needs. You can use my code, tweak it to suit your own needs and deploy to your own AWS account.
Tech used :
- Node.js
- serverless framework
- github actions
PREREQUISITES
STEPS TO SETUP
- Clone this repo into your local machine
- Create a
.env.yml
file at the root of the directory
- Open the
.sample.env.yml
file and copy-paste the contents into the .env.yml
file.
- Follow the comments to replace the values of the environment variables according to your setup inside the
.env.yml
file.
- Go to
src/index.js
and set the value for the constants defined in lines 5-9 as per your own needs.
- Commit the changes to your local git repository.
- Create a new repo on GitHub and go to settings > secrets for the repo. This is where we store secrets for a GitHub action CI/CD pipeline.
- To add a secret, click on
New repository secret
. Follow this step to add the following secrets:
AWS_ACCESS_KEY_ID
: access key id of the AWS account to which the lambda shall be deployed. The account must have relevant IAM permissions for Lambda and Cloudwatch.
AWS_SECRET_ACCESS_KEY
: secret access key of the above mentioned account
ENV
: copy paste the contents of your .env.yml
file here
- Add this repo as a remote origin to your local repo and push the code to
main
branch using git push origin main
.
- Visit the actions tab to check the deployment status. Once the deployment is successful, a Lambda function must be created in your AWS Account.
- Open your AWS Lambda console and find your newly deployed lambda function
- Open the function in your conosle and click on the configuration tab.
- Click on Triggers > Add Trigger.
- From the dropdown that appears, select
EventBridge(CloudWatch Events)
- Under the 'Rule' section, selecte 'Create New Rule'
- Enter a Rule Name (eg: 'hourly' or 'everysixhours', etc...)
- Under 'Rule Type' select 'Schedule Expression'
- Enter the CRON or rate expression in 'Schedule Expression' text box (eg : rate(1 hour) means it would be triggered every one hour)
- Click on 'Add' to finally add the trigger.
- That's it, you're all set !
Feel free to open issues / submit pull requests to make improvements :)