Skip to content
perpil edited this page Jun 11, 2023 · 54 revisions

speedrun required
⚠️ The blocks on this page require you to approve permissions for the Speedrun Prod Github App. These permissions enable Speedrun to authorize access to AWS roles based on your GitHub username, teams and organizations.

💡 Tip Click the Code tab on any block to see the underlying raw Markdown. Click the copy icon to copy the underlying Markdown to the clipboard.

Querying CloudWatch Logs

As a side hustle, you landed a rover on the moon to collect moon rocks. The rover emits telemetry logs and metrics to CloudWatch and you want to see why it keeps throwing faults at the 55th minute of every hour and how many rocks you are missing out on.

  1. Click the Open AWS Console button to go to the AWS Console all set up.
  2. Click Run query in the console to execute it.

If you'd like, change the region in the Speedrun toolbar at the top of this page and to do the same thing in another account and region.

#CWLInsights
filter fault>0
| stats count(*), sum(rocks) by details, bin(1m)

Now you want to see what timestamps you got more than a certain number of rocks.

  1. Click Open AWS Console then Ok after you've selected your number of rocks.
  2. Finally click Run query in the console to execute it.
#CWLInsights
filter fault<1 and rocks > ~~~Rocks Collected {type:'select',options:['10','20','50']}~~~ |
display @timestamp, rocks |
sort by rocks desc

Poking around in S3

Nina from accounts payable had an extra moment and wants to see the new sticker designs before the Bobs see them. You oblige with this link to go to the sticker bucket for the region. I'll leave off the exact buttons you need to click, see if you understand the interface enough to do it.

#S3Bucket

But Nina has to transfer a call before you show her, so you improve the tool to go straight to the file.

#S3Object
~~~key=Sticker {type:'select', options: {'No Backspace Crew':'nobackspacecrew.svg','Speedrun':'speedrun.svg'}}~~~

Invoking a Lambda

Now you want someone to say "Hello" to you, but no one is in the office, so you get a Lambda to greet you instead. Paste what it copies to the clipboard somewhere to see the result after you've run it.

#!lambda {functionName:"HelloWorldService"}
{
  "name": "~~~Name {default:'Samuel L. Jackson'}~~~"
}

This demo is sweet, but you're hungry. You go to the break room and use the Lambda powered warm nuts dispenser. Somehow it knows your GitHub login! Paste what it copies to the clipboard somewhere to see the result after you've run it.

#!lambda {functionUrl:"${lambdaFunctionUrl}"}
{
  "warmed": ~~~Warm the nuts? {type: 'checkbox', default:true}~~~
}

Invoking a Step Function

Now it's dinner time. You heard from your coworker George that there is a place called "Hot Soup" down the street that serves delicious soups but the owner Yev can be a bit feisty. They've moved to using an online ordering system powered by Step Functions. You decide to order a soup. Click the Run button below to put in your soup order. See if Yev decides to give you a soup.

#!stepfunction {functionName:'HotSoup', inputTitle:'Order a soup', required:true}
{
   "message" : ~~~Soup order {type:'textarea', transform:'JSON.stringify(value)', label:"Enter your soup order. Ask nicely and don't push it."}~~~
}

Querying a DynamoDB table

Your boss wants to know how many occurrences of a word are in the Nickelback song Photograph. Luckily you have a database with the word frequency mirrored across two AWS accounts in separate regions for availability. You whip this together, slack him the link. He 😍's it and you get a raise.

#DDBItem {tableName:'nickleback-lyrics'}
~~~partitionKey=Lyric {transform:'value.toLowerCase().trim()', default:'photograph'}~~~

⚠️ Note To run this next command; first install and run srinit to authenticate your command line and install the AWS CLI (if you don't already have it). Feel free to skip to Deep link to a site if you'd rather do these steps later.

And because your Mom's Dec PDP-1 doesn't have a browser, and she already has everything in the JC Penny catalog, you make her a Nickelback lyric command line tool for Christmas:

#copy.withCreds {forceNewCreds:true}
aws dynamodb get-item --table-name nickleback-lyrics \
--key $'{"word":{"S":"~~~partitionKey=Lyric {transform:'bashEscape(value.toLowerCase().trim())', default:'photograph'}~~~"}}' \
--query Item.occurences \
--output text

Deep link to a site

You want to tell everyone about when you demoed to the CEO of GitHub, but occasionally rick-roll the recipient.

#link
https://youtu.be/${Math.random() < (1.0/10)?'dQw4w9WgXcQ':'fu_MC0rujXw'}

But then you're like, why don't I just embed the video instead:

#!YouTube
fu_MC0rujXw

Copy the current epoch time to the clipboard

You can never remember the command to get milliseconds since 1970, for some reason everyone needs it. So you make this.

#copy
//Epoch time is
${Date.now()}

Complaint Letter

You want to file a complaint about the documentation quality. Note You must be signed into GitHub for it to populate your username in the signature.

#download {'filename':'complaint.txt', 'words':['difficult','unclear','obtuse','unpolished','hard']}
${dayjs().format('MM-DD-YYYY')}

Dear ~~~Name {default:'Adam'}~~~,

Your docs did me dirty.  There were so many steps! They were so ${randWord(words)}!
I've submitted a pull request to improve them and make them easier.

Cheers,
${user}

What is this sorcery?

The Getting Started page goes into more details about the markdown syntax and how it all works.

Below if you look for #srConfig you'll see how little config is powering all of this. The trust policy on the Demo role is set to allow any GitHub user that is using the Speedrun app.

#srConfig
{
    role: 'Demo',
    services: {
       DecacornService: {
          bucket:"speedrun-demo-stickers-${region}",
          logGroups:"/aws/lambda/MoonRocksService",
          regions: {
            "us-west-2" : {
              account: '205348963185',
              lambdaFunctionUrl: 'a2bocmnz4calxsxunj4ht7uibm0qcbsm'
            },
            "us-east-2" : {
              account: '330023003565',
              lambdaFunctionUrl: 'g37mubrn2y3mlbqacsow64wz4m0rfjky'
            }
          } 
       } 
    },
    "function:randWord": {
      "args" : ["words"],
      "body" : "return words[Math.floor(Math.random()*words.length)]"
    },
    srServiceFilter:'DecacornService',
    srShowConfig: true
}
Super Secret Squirrel Clearance Required

Administrator access

Sorry, you won't have access to this elevated privilege role, it is for perpil only. But you can click these red buttons anyway and get denied.

AWS Console

#federateService {role:'Administrator'}

CLI

#copy.withCreds {role:'Administrator'}
Clone this wiki locally