Skip to content

Getting Started

perpil edited this page Dec 2, 2022 · 90 revisions

Installation

  1. Install Tampermonkey if you don't already have it.
  2. Install Speedrun
  3. Reload this page

Play with a live demo

Get a taste for the power on the demo page.

Learn the basics

Using a template

Each Speedrun block starts with the name of a template which tells Speedrun what to do and reduces the amount of code you need to write. The most basic template is the copy template which copies something to the clipboard. To get Speedrun to find and wire up your code, wrap your content with code fences (```), put the #template you want to use on a new line and enter any content below that.

💡 Tip Click the Code tab to see the underlying Markdown for an entry. Click the copy icon to copy the underlying Markdown to the clipboard.

This will use the copy template to copy something to the clipboard.

#copy
This was copied by ${user}

Read more about templates, the different template types and how to build your own here.

Prompting for inputs

To prompt the user, wrap the prompt name with 3 tildes (~~~) on each side. Speedrun will replace it with what the user enters.

#copy
This is ${user}'s favorite color: ~~~Favorite Color~~~

Read more about prompts, changing the prompt type, default values and transforming inputs here.

Running JavaScript

To use JavaScript wrap content with ${}

#copy
This is ${user.toUpperCase()}'s favorite color: ~~~Favorite Color~~~

Read more about using JavaScript, helper functions and defining your own functions here.

Learning the User Interface

Find out how to use the toolbar and the interface here: User Interface Documentation

Configuration

Speedrun configuration is used to define the services and regions that appear in the toolbar. It also sets variables, like optional AWS account and role used to set the context for each Speedrun block. You can see the variables that are set by clicking the Debug tab of any Speedrun block. Read about configuring Speedrun for your environment here

Getting AWS Credentials

Hold on champ, first you need to configure your accounts and roles.

Create Speedrun Roles

Follow this wiki to create the necessary Speedrun roles and to register your AWS account

Install srinit

srinit is a command line tool that authenticates you with GitHub so you can assume the Speedrun roles you have access to

#copy
python3 -m pip install --extra-index-url https://speedrun.nobackspacecrew.com/packages srinit

Now run srinit to authenticate so you can run AWS CLI commands. This needs to be done once per day.

#copy
srinit

Using Credentials

If you've added your account and role to the settings, you can now use them.

#federate

If you have the AWS CLI installed, you can run commands with credentials like this.

#copy.withCreds
aws sts get-caller-identity

How it works

Speedrun takes a template that defines what you want it to do, sets the variables from the context and evaluates the JavaScript in the browser. It can use any of the following to do what you need to do.

  1. Markdown content Markdown content, referenced by ${content} in templates is what you put in your code fence. It can be any text content including things like json, a url, a command line or JavaScript code.
  2. Prompts Prompts prompt the user for input. By default, they are set to what was entered last time the user was prompted for the same thing.
  3. Credentials Speedrun operates as a credentials broker, if the authenticated GitHub user is authorized to assume the role (specified by the role variable) in the account (specified by the account variable), it can get the necessary credentials to federate into the AWS Console or get credentials for the command line.
  4. Configuration Configuration defines things like what AWS accounts and roles to use, what your services are called and any configuration you want to associate with your services like the log groups they use, or the stage.
  5. JavaScript JavaScript is used to manipulate inputs, reference configuration and set default values.

Speedrun does the following when you load a markdown page.

  1. Finds all the configuration for current page and uses it to build the toolbar
  2. Looks for code fences that use a defined template, adds buttons to them and renders a preview.
  3. When the do it button is clicked; prompt for any inputs, resolve any variables, and run all JavaScript code to process the template.
  4. Depending on the template type, copy the result to the clipboard, open a link, federate into the AWS Console or download the result as a file.

Clone this wiki locally