I'm trying to follow the <instructions to use the ...
# sst
s
I'm trying to follow the instructions to use the examples repository so I can try out SST in scenarios I'm not familiar with (e.g. a python API), but I can't seem to get it to work as expected. I assume the command is supposed to checkout the specified project, but that doesn't appear to be happening. Instead, a default "Hello World" project is being created
Here's the output of me following the instructions in the examples repository to initialize the rest-api-dynamodb example.
Copy code
āžœ  dev npm init serverless-stack --example rest-api-dynamodb
Need to install the following packages:
  create-serverless-stack
Ok to proceed? (y) y

Initializing a new Serverless Stack JavaScript project
Creating rest-api-dynamodb/ directory
Creating template for: javascript
Installing packages
npm WARN deprecated urix@0.1.0: Please see <https://github.com/lydell/urix#deprecated>
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated resolve-url@0.2.1: <https://github.com/lydell/resolve-url#deprecated>
npm WARN deprecated sane@4.1.0: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See <https://v8.dev/blog/math-random> for details.
npm WARN deprecated uuid@3.3.2: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See <https://v8.dev/blog/math-random> for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see <https://github.com/request/request/issues/3142>
npm WARN deprecated node-pre-gyp@0.13.0: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future

added 1592 packages, and audited 1617 packages in 1m

99 packages are looking for funding
  run `npm fund` for details

31 vulnerabilities (2 moderate, 29 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
Success! Created rest-api-dynamodb in /Users/sgeoghegan/dev/rest-api-dynamodb
You can run:

  npm run start
    Start the local development environment

  npm run test
    Run your tests

  npm run build
    Build your app and synthesize your stacks

  npm run deploy
    Deploy all your stacks and create your AWS resources

  npm run remove
    Remove all your stacks and all their resources from AWS

To get started:

  cd rest-api-dynamodb
  npm run start

Have fun!
āžœ  dev cd rest-api-dynamodb 
āžœ  rest-api-dynamodb more stacks/MyStack.js 
import * as sst from "@serverless-stack/resources";

export default class MyStack extends sst.Stack {
  constructor(scope, id, props) {
    super(scope, id, props);

    // Create a HTTP API
    const api = new sst.Api(this, "Api", {
      routes: {
        "GET /": "src/lambda.handler",
      },
    });

    // Show the endpoint in the output
    this.addOutputs({
      "ApiEndpoint": api.url,
    });
  }
}
I expected the output of
more stacks/MyStack.js
to be the MyStack.js from the rest-api-dynamodb example repo, but that is not the case. What am I doing wrong?
I believe I'm on the latest version of sst (from my package.json)
Copy code
{
  "name": "rest-api-dynamodb",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "test": "sst test",
    "start": "sst start",
    "build": "sst build",
    "deploy": "sst deploy",
    "remove": "sst remove"
  },
  "devDependencies": {
    "@aws-cdk/assert": "1.126.0"
  },
  "dependencies": {
    "@serverless-stack/cli": "0.46.1",
    "@serverless-stack/resources": "0.46.1",
    "@aws-cdk/core": "1.126.0"
  }
}
m
@Seth Geoghegan could you try adding @latest after serverless-stack and try?
npm init serverless-stack@latest --example rest-api-dynamodb
or try using
yarn
t
^ that should be it
Wait maybe we broke something somewhere hm
Ah it needs to be
--example=rest-api-dynamodb
the library we're using for flag parsing is getting confused
m
Do we need to place an
=
?
t
yeah
s
Great, I'll give this a try when I'm back at my laptop šŸ™‚
I was able to get this to work by executing
npx create-serverless-stack@latest --example=rest-api-dynamodb
as opposed to the instructions in the example repo, which were
npm init serverless-stack --example=rest-api-dynamodb
I suspect
create-serverless-stack
is the preferred way to download examples and
npm init serverless-stack
was the previous method?