Skip to content

1. Start Here

Mandy edited this page Oct 20, 2023 · 4 revisions

1. Prerequisites πŸ“βœ…

  1. Laptop or Computer (Mac/Linux/Windows) πŸ’»

  2. Internet access πŸ›œ

  3. Practical working knowledge of a programming language, preferably one of the supported SDK languages listed below. πŸ“πŸ”πŸ‘€

  4. Git https://git-scm.com/book/en/v2/Getting-Started-Installing-Git πŸ“πŸ”πŸ‘€

  5. Your preferred development language tooling πŸ’»πŸ“*️⃣

  • Fastly currently supports the following languages with SDKs:
  1. JavaScript / NodeJS https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
  • Compiling JavaScript applications for Compute requires a recent version of Node.js (>= 16.6). Before building the app, you also need to be able to install dependencies using the npm package manager or an alternative.
  1. Rust https://www.rust-lang.org/tools/install
  • Compiling Rust applications for Compute requires that you have rustup installed, along with Rust's stable channel and the wasm32-wasi toolchain. Install Rust and its dependencies using rustup so you can begin building Compute services. More detailed steps can be found at https://developer.fastly.com/learning/compute/#install-language-tooling under the "Rust" section.
  1. Go https://go.dev/doc/install
  • Compiling Go applications for Compute requires Go 1.21 or higher.
  1. TinyGo https://tinygo.org/getting-started/install/
  • Compiling TinyGo applications for Compute requires TinyGo 0.26.0 or higher.
  • You may also choose to use another language if you are prepared and able to compile your code to a WASM binary (This will be much more work and possibly too time-consuming during this workshop.)
  1. Your IDE (Visual Studio Code) or code editor (VIM ftw!) βœ…

  2. (Mac only - this step is not required for Windows or Linux) Homebrew https://brew.sh/ (There are pre-built binaries for Linux/Windows.) 🍏

  3. Install the Fastly CLI. πŸ––

Fastly's CLI "fastly" is an open-source command line tool for interacting with the Fastly API. Use it to create services, manage backends and domains, upload VCL or build and deploy Compute packages. Convenient access to Fastly from where you are working with your code, or from your CI environment https://developer.fastly.com/learning/tools/cli/#installing

  1. Check the installation πŸ› οΈ

$ fastly version

2. Getting Started Instructions πŸƒβ€β™€οΈ

  1. Create a new empty directory for your project and go into it

mkdir stardust && cd stardust (or the equivalent in your OS)

In this case we are naming the project "stardust" but feel free to use a name of your choice.

  1. Initialise a project

$ fastly compute init

Follow the instructions in the prompts.

  • If you are using JavaScript, you should say yes to run npm install.
  • I am using the project name "stardust".
Untitled 2
  1. Locally run and test

$ fastly compute serve

  • You will see a warning about no backends defined, just ignore that for now.

fastly-compute-init

Visit the URL provided in the output. It should look like this "http://127.0.0.1:7676". If everything works as expected you should see this in the terminal:

Screenshot 2023-10-17 at 12 39 41 pm

In your browser you should see this:

Screenshot 2023-10-17 at 12 40 15 pm

3. Publish and Run on Fastly πŸ“šπŸŒŸπŸŒˆ

If you are only developing locally for now, this step is OPTIONAL, and you can go to the next step. Return here once you are ready to push to the Fastly platform.

1. Token Creation

Use a token supplied to you in the Workshop, or create a new Fastly API User Token https://docs.fastly.com/en/guides/using-api-tokens (not an Automation token for now).

2. Set up your credentials in the Fastly CLI. This is optional until you reach the publish or deploy step and want to push your code to Fastly. For this, you will need your API Token from the previous step.

$ fastly profile create

Note: if you did create an automation token in the previous step instead of a user token, you will need to supply the "--automation-token" flag. This is NOT required for a user token.

$ fastly profile create --automation-token

3. Push to Fastly

Follow the prompts to publish your compute service to Fastly.

$ fastly compute publish

Once the code has been pushed to the Fastly platform, the output log will provide a URL to your new service.

4. Next Steps

Once you are ready, please go to https://github.com/mandyscott/EdgeComputeWorkshop/wiki/2.-Edge-Compute-Workshop