Run daily in AWS Lambda this code generates a draft email in SendGrid pulling the BOM forecast data for Yulara (Uluṟu).
It retrieves the Handlebars template from Sendgrid and executes a first pass render with both the forecast data and also the fixed annual sunrise, sunset and opening hours 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 4:15 pm Darwin time. After which the UKTNP staff can log into SendGrid to review the draft message, adjust any messaging where required, and press send.
This project is set up and deployed using AWS CDK.
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>"
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
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 uluruWeather/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 uluruWeather/sendgridApiKey --description "SendGrid API key" --secret-string "<key>"