Autosam
Description
Autosam is a project that I created to automate the Akamai Cloudlets Edge Redirect from end to end, including add new rules, remove duplicated rules if there are any, push to staging, test in staging, push to production, test in production.
Design
Autosam is written in Bash and Python, and it utilizes a few technologies: slack, hubot, AWS DynamoDB and Cloudlets API.
Here is the high level architecture architecture diagram
Workflow
Here is the detailed workflow design workflow diagram
Lifecycle
Autosam treats every redirect as a job. And job has different status in its lifecycle.
lifecycle diagram
Usage
Autosam supports two methods of submitting redirect jobs.
Slack bot
This requires to create a hubot and integrate it into Slack. The code can be found in myHubot repo. lib/autosam.js and scripts/autosam.js autosam_botText file
This allows you to do multiple redirects all in one go, just add all your redirects in a text file, one redirect per line. Then give it to autosam to process.# for adding new redirects ./autosam_v2.sh <file> # for testing ./test_staging.sh ./test_production.shBest practice
As Akamai takes a long time to propagate the configuration changes, it is a good idea to consolidate as many redirects as possible into one go. In my environment, I created a cron job to run every 30 minutes. And users submit the redirect jobs via talking to the Slack bot that is shown above.
0,30 08-17 * * 1-5 cd /home/autosam/cloudlets; ./all-in-one.sh >> logAkamai will deny your API calls if the time in your machine is not correct. The best way to avoid that is to adjust your time before executing autosam. Here is a command you can use:
sudo date -s "$(curl -sD - google.com | grep '^Date:' | cut -d' ' -f3-6)Z"
Redirect types
Autosam supports both basic URL redirects and URL with query string. This can be extended to support more types in the Cloudlets module
Log in or sign up for Devpost to join the conversation.