Skip to content

Daily email via SendGrid to Kakadu CTOs/interested parties with the latest road and site access information.

Notifications You must be signed in to change notification settings

parksaustralia/access-report

Repository files navigation

Daily access report

Run daily in AWS Lambda this code generates an email in SendGrid after pulling the current access report data from CloudCannon.

It retrieves the Handlebars template from Sendgrid and executes a first pass render with the report data.

It posts the rendered HTML back to SendGrid as a draft email. The mailing lists and unsubscribe groups are set automatically.

The code runs daily at 10:00 am Darwin time and creates a scheduled single send in SendGrid which is scheduled to automatically send at 10:30 am Darwin time.

This project is set up and deployed using AWS CDK.

Development

This project requires Node.js 12.x and that you have AWS credentials configured in order to deploy.

  • npm install
  • npm run test
  • npm run debug

The project includes a Github Codespaces config that will create an environment with all of the require dependencies installed. All that is required after creating the codespace is to run aws configure and enter your AWS API keys and region.

You may also like to set your SendGrid API key for local development and debugging:

export SENDGRID_API_KEY="SG.<snip>"

Deployment

First the SendGrid API key must be set in the account using AWS secrets manager.

Then you can deploy the stack with:

npm run cdk deploy

SendGrid API key

The SendGrid API key is stored in AWS Secrets Manager and is pulled when deploying the application.

To set the key:

aws secretsmanager create-secret --name accessReport/sendgridApiKey --description "SendGrid API key" --secret-string "<key>"

To change the key, the secret needs to first be updated and then the CDK stack redeployed:

aws secretsmanager update-secret --name accessReport/sendgridApiKey --description "SendGrid API key" --secret-string "<key>"

About

Daily email via SendGrid to Kakadu CTOs/interested parties with the latest road and site access information.

Topics

Resources

Stars

Watchers

Forks