A utility that runs on AWS Lambda to rename and tag commute rides on Strava.
It is inspired by Alex Muller's lambda-strava-commute-namer. I started from scratch because I wanted to try out:
- Lambda's native support for Go
- Strava's webhook push subscriptions
- Config and deployment with Terraform
-
Install Terraform.
-
Export your
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
. -
Create an S3 bucket to store state and initialise Terraform:
make init BUCKET_SUFFIX=<your_suffix>
-
Create an API application from your settings on Strava with a callback domain of
localhost:8080
. -
Create an API token that has
write
andview_private
scopes for your account using dcarley/oauth2-cli:oauth2-cli \ -scope write,view_private \ -id <your_client_id> \ -secret <your_client_secret> \ -auth https://www.strava.com/oauth/authorize \ -token https://www.strava.com/oauth/token
-
Email developers@strava.com to ask them to enable webhook push subscriptions for your application. Include your application client ID and a brief description of what your application does.
Write a config file to dist/config.json
in the following format:
{
"gear_id": "b12345",
"locations": {
"London": {
"min": [-0.510375, 51.286758],
"max": [0.334015, 51.691875]
},
"Sheffield": {
"min": [-1.801472, 53.304512],
"max": [-1.324669, 53.503128]
}
}
}
Notes about the format:
- The name of each location will be append to activities that have a matching start and/or end location. You can use a bounding box utility to generate the longitude and latitude co-ordinates.
- The
gear_id
is optional. If present all activities with matching locations will be tagged with it. You can get the ID from the URL when looking at your bike/shoes on Strava, but you need to prefix it withb
for bikes andg
for shoes.
-
Export your Strava API token as
STRAVA_API_TOKEN
. -
Build, package, and deploy:
make
-
Create a push subscription if you're deploying for the first time or the URL has changed:
make register \ STRAVA_CLIENT_ID=<your_client_id> \ STRAVA_CLIENT_SECRET=<your_client_secret>