Creating a scheduled Lambda or Lambda Cron

This guide revolves around a basic twitter bot implementation which posts a single tweet to the same twitter account every 6 hours.

It allows any Node script (or other if you fancy doing the work to get PHP/Python etc running) to be triggered on any schedule, from every minute to once every year.

Several steps are involved in getting this all up and running:

  • Get our Twitter auth details
  • Write our bot code
  • Create the Lambda in AWS Console
  • Add Environmental variables to keep our security details safe
  • Test our Lambda function
  • Set up a Cloudwatch trigger to act as the scheduler
  • Confirm the schedule is running as expected

Get our Twitter auth details

Open developer.twitter.com and consider which account you’re going to post tweets to.

You may need to sign up and verify your account. Do all that, or just login.

Once you’re in create a new app. Click to create or view keys / access details and ensure you have an App Token, App Secret, User Secret and User Token. So four hashes in total. Two tokens and two secrets.

Also check that your user details have read and write access so we can post tweet updates.

Continue reading

Migrating away from Mapbox Studio Classic Styles

If you’re using Mapbox static or interactive maps you might still be using the old method for pulling in a style.

Recognise either of these?

L.mapbox.map('map-id', 'account.styleID')

https://api.tiles.mapbox.com/v4/mapbox.style/

Well there are newer ways to do things now, and in the near future these will stop working for you.

First step is to update the version of the javascript library you’re using (if you are) to at least v2.4.0. So any direct links to mapbox javascript files or you might have it referenced in your composer or npm package list.

Continue reading