I'm trying to convert an existing CDK project to S...
# help
j
I'm trying to convert an existing CDK project to SST and I'm sure I missed something because I'm getting this:
Copy code
(base) jonholman@jonlaptop serverless-benchmarks % AWS_PROFILE=sso-jon-stuff npx sst start
Using stage: dev
Preparing your SST app

=======================
 Deploying debug stack
=======================

node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module '/Users/jonholman/repos/personal/serverless-benchmarks/.build/lib'
Require stack:
- /Users/jonholman/repos/personal/serverless-benchmarks/node_modules/@serverless-stack/cli/assets/debug-stack/bin/index.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/jonholman/repos/personal/serverless-benchmarks/node_modules/@serverless-stack/cli/assets/debug-stack/bin/index.js:28:17)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/jonholman/repos/personal/serverless-benchmarks/node_modules/@serverless-stack/cli/assets/debug-stack/bin/index.js'
  ]
}
Subprocess exited with error 1
There was an error synthesizing your app.
any ideas?
AWS_PROFILE=sso-jon-stuff cdk deploy --all --require-approval never
is still working. I thought I brought everything I needed over.
I just learned that the main SST file must be named index.ts
f
Hey @Jon Holman, did you get this to work?
I believe I have this resolved. But I think I'm going to start over and just follow these nice instructions instead of making up my own process 🙂
f
Haha, you can change the path to
stacks/index.ts
in
sst.json
Let me know how it goes.
j
yeah, I was trying to change as little as possible, I finally narrowed it down to when I make the file
stacks/anythingElse.ts
the problems started
Will do, I think I'll be ok now.
Thanks
@Frank in addition to a "context" block the project I'm working on has an "app" and "watch" block in cdk.json as well.
Can SST use those keys?
f
what’s in them?
Btw this is not relevant to the name of your SST index file https://github.com/serverless-stack/serverless-stack/blob/3d85ccc2fef9898683c6bfff02c95dbd10da9020/packages/cli/assets/cdk-wrapper/run.js#L44 SST internally compiles the SST app into a standard CDK app, which has
lib/index.js
You can name it
stacks/anythingElse.ts
, u’d just have to tell SST where to find it in
sst.json
j
huh. I was trying that and having problems
Those other keys have:
Copy code
"app": "npx ts-node --prefer-ts-exts bin/serverless-benchmarks.ts",
  "watch": {
    "include": [
      "**"
    ],
    "exclude": [
      "README.md",
      "cdk*.json",
      "**/*.d.ts",
      "**/*.js",
      "tsconfig.json",
      "package*.json",
      "yarn.lock",
      "node_modules",
      "test"
    ]
  },
f
huh. I was trying that and having problems
Do u mean you can’t rename
stacks/index.ts
to
stacks/anythingElse.ts
? Can I see what ur
sst.json
looks like?
j
@Frank sorry, I just saw your response. Yes, that's what I'm saying and I just reproduced it again. Before the rename with index.js everything deployed fine. All I did was rename the file and update sst.json to match and now I cannot deploy. sst.json:
Copy code
{
  "name": "serverless-benchmarks",
  "region": "us-east-1",
  "main": "stacks/anythingElse.ts"
}
Copy code
serverless-benchmarks % AWS_PROFILE=sso-jon-test npx sst deploy --stage prod
Using stage: prod
Preparing your SST app

Cannot find app handler. There was a problem transpiling the source.


There was an error synthesizing your app.
f
I’m able to reproduce this issue. Working on a fix ✨
Hey @Jon Holman, this is fixed in 0.69.3.
j
Awesome, thanks @Frank