Skip to content

Instantly share code, notes, and snippets.

@serkanh
Created July 24, 2019 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save serkanh/6017da198a0902388ac7298fba81c252 to your computer and use it in GitHub Desktop.
Save serkanh/6017da198a0902388ac7298fba81c252 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ $# -lt 3 ]; then
echo "To update fastly dynamic vcls"
echo "----------------------------"
echo "https://docs.fastly.com/vcl/vcl-snippets/using-dynamic-vcl-snippets/"
echo "$0 <fastly-key> <service-number> <revision-number>"
exit 1
fi
SERVICE_NUMBER=$1
FASTLY_KEY=$2
REVISION_NUMBER=$3
curl -X DELETE -s https://api.fastly.com/service/${SERVICE_NUMBER}/version/${REVISION_NUMBER}/snippet/customlogging_model -H "Fastly-Key:${FASTLY_KEY}"
curl -X POST -s https://api.fastly.com/service/${SERVICE_NUMBER}/version/${REVISION_NUMBER}/snippet -H "Fastly-Key:${FASTLY_KEY}" -H 'Content-Type: application/x-www-form-urlencoded' --data $'name=customlogging_model&type=recv&dynamic=1&content=if (req.url ~ "^\/(acura|alfa-romeo|aston-martin|audi|bentley|bmw|bugatti|buick|cadillac|chevrolet|chrysler|dodge|ferrari|fiat|ford|genesis|gmc|honda|hyundai|infiniti|jaguar|jeep|kia|koenigsegg|lamborghini|land-rover|lexus|lincoln|lotus|maserati|mazda|mclaren|mercedes-amg|mercedes-benz|mercedes-maybach|mini|mitsubishi|nissan|pagani|polestar|porsche|ram|rolls-royce|scion|smart|spyker|subaru|tesla|toyota|volkswagen|volvo)\/[a-zA-Z\d\-_]*(\\?.*)?$"){set req.http.X-Log-URL = "true";}';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment