Video:

Go Serverless REST API - Project Setup

November 27, 2021

Course Instructor: Elliot Forbes

Hey Gophers! My name is Elliot and I'm the creator of TutorialEdge and I've been working with Go systems for roughly 5 years now.

Twitter: @Elliot_f

In this video, we are going to be laying the foundations for our awesome new serverless application.

We’ll be looking at how we can use the npx command in order to bootstrap our project directory and give us a base which we can build our new empire on.

Bootstrapping The Project

There are a few things you’ll need in order to run the bootstrapping command. Firstly, you are going to need npm or the Node Package Manager installed on your machine, you’ll also need Node with a version greater than or equal to 10.15.1 at the time at which I’m writing the script for this video.

$ npm -v
8.1.3
$ node -v
v16.3.0

AWS CLI Setup

Serverless-stack works on top of AWS Lambda, and as such, you’ll need to have an AWS account set up, and you’ll also need the aws CLI installed on your machine with the correct credentials setup.

I’ve currently got what is presumably an older version installed:

$ aws --v
aws-cli/1.14.57 Python/2.7.18 Darwin/21.1.0 botocore/1.9.10

And I’m able to validate that I have my credentials setup by being able to run:

$ aws s3 ls

Now in this particular case, this then outputs all of the S3 buckets that I’ve created over my lifetime and forgotten about. If you haven’t set up your credentials properly then it should show an error about no credentials.

Running create-serverless-stack

Ok, Let’s open up a terminal, and let’s use the node package runner npx in order to create our new app:

$ npx create-serverless-stack@latest --language go go-sst-rest-api
$ cd go-sst-rest-api

Awesome, we now have a bootstrapped project!

Running Our Project

We have our new project all ready to go. We can now attempt to run this locally and see if it all works!

$ npx sst start