Howdy. Beginner SST question here. I wish to be ab...
# help
p
Howdy. Beginner SST question here. I wish to be able to use the local, live Lambda development feature for my lambdas (shortening the code-2-test time is so critical). I'm currently using Serverless and have 68 lambdas as well as infrastructure with some buckets, DDB tables, cognito, custom domains etc. There are both public endpoints as well as private ones. To be able to use live dev, I need to define my lambdas in SST, right? Would it be possible then to just define 1 or 2 lambdas in SST, deploy the mock stubs and have the rest of my setup be defined in SLS? So, I deploy the mock stubs by defining them in SST and overwriting the previously deployed functions and run
sst start
. When I'm done developing, I deploy again to make sure I replace the mocked functions. Is this correctly understood? Thank you for your time!
f
Hi @Pål Brattberg, are you trying to do something like: ie. your SLS service has 1 APIG endpoint + 1 lambda function. And you want to deploy just the lambda function in an SST project.
So when you trigger the APIG endpoint defined in SLS, the Lambda function defined in SST gets invoked, hence you can live develop it.
Is that what you are trying to do?
p
That's one scenario I would like, but some functions may now use apig, but instead be triggered by s3 events, eventbridge or using direct API invocation. Can I replace functions one by one, or do I need to move larger chunks of my deployment setup to SST/CDK?
I guess that's my main Q. Can I migrate my Serverless application that uses many
serverless.yml
-files, for many services towards SST piecemeal and enable moving 1 function at a time to SST to be able to make use of Live dev?
It's really faster development turnaround time I'm after. Deploying my full SLS project takes upwards of 15 mins, and a single service (a single
serverless.yml
file) might take 1-2 mins.
f
Got it. What you are proposing is a bit tricky to do. Let me explain.
Say u have a SLS service with service name my-api-service, and it has 1 APIG endpoint + 1 lambda function.
SLS creates a CloudFormation stack named dev-my-api-service (ie. deploying to dev stage), with the APIG and Lambda function in there.
Now if you want to replace that Lambda function with one in your SST app you would have to create a stack in SST with the same name ‘dev-my-api-service’, and in the stack create a Lambda function with the same function name.
But if you just have the Lambda function in the SST app, when you deploy the entire stack ‘dev-my-api-service’ will be replaced by the one from SST.
This will remove the APIG endpoint.
p
I see. So that means that I will have to migrate a whole stack at a time then?
f
Yeah
U can definitely move 1 off Lambdas out of your SLS stack to SST.
p
Ok. Thankfully I have multiple stacks (17 right now 😱 )
f
For example, in one of your SLS stack, if you have a SNS topic that triggers a Lambda function. You can remove them from your SLS service (since it is easy to recreate and migrate a SNS topic). And re-create them in your SST app.
p
Yeah, might be smarter. Move one out of the sls stack and into a new sst stack you mean?
f
yeah
In this case, you would end up with 18 stack. 17 from SLS, and 1 from SST app. And that stack only have 1 SNS topic and 1 Lambda function.
p
ok. sounds very doable!
Btw; I have trouble running this in
eu-west-1
, that should work, right?
f
Yeah, what’s the error are you getting?
p
It complains that the deployment bucket already exists, even though I delete it right before. Seems like its run twice perhaps
I also use
aws-vault
btw
f
This is happening when you run
sst start
?
p
❰pal❙~/temp/simple-sst❱00:39  ✔≻ aws-vault exec test-admin -- yarn sst deploy                                                                                                          00:39:41
yarn run v1.22.10
$ /Users/pal/temp/simple-sst/node_modules/.bin/sst deploy
Preparing your SST app
Transpiling source
Linting source
Deploying stacks
Building Lambda function src/lambda.handler
Linting Lambda function source
test-supersimpletesttemp-peasy: deploying...
:x:  test-supersimpletesttemp-peasy failed: Error: This stack uses assets, so the toolkit stack must be deployed to the environment (Run "cdk bootstrap <aws://XXXXXXXXXX/eu-west-1>")
at Object.addMetadataAssetsToManifest (/Users/pal/temp/simple-sst/node_modules/sst-cdk/lib/assets.ts:27:11)
at Object.deployStack (/Users/pal/temp/simple-sst/node_modules/sst-cdk/lib/api/deploy-stack.ts:221:29)
at processTicksAndRejections (node:internal/process/task_queues:94:5)
at CdkToolkit.deploy (/Users/pal/temp/simple-sst/node_modules/sst-cdk/lib/cdk-toolkit.ts:194:24)
at Object.deployAsync (/Users/pal/temp/simple-sst/node_modules/sst-cdk/lib/serverless-stack.ts:122:15)
at /Users/pal/temp/simple-sst/node_modules/@serverless-stack/core/index.js:71:17
at async Promise.all (index 0)
at deployStacks (/Users/pal/temp/simple-sst/node_modules/@serverless-stack/core/index.js:48:5)
at Object.parallelDeploy (/Users/pal/temp/simple-sst/node_modules/@serverless-stack/core/index.js:446:3)
at parallelDeploy (/Users/pal/temp/simple-sst/node_modules/@serverless-stack/cli/scripts/util/cdkHelpers.js:426:15)
Building Lambda function src/lambda.handler
Linting Lambda function source
:hourglass_flowing_sand:  Bootstrapping environment <aws://XXXXXXXXXX/eu-west-1>...
:hourglass_flowing_sand:  Bootstrapping environment <aws://XXXXXXXXXX/eu-west-1>...
Trusted accounts:   (none)
Using default execution policy of 'arn:aws:iam::aws:policy/AdministratorAccess'. Pass '--cloudformation-execution-policies' to customize.
Trusted accounts:   (none)
Using default execution policy of 'arn:aws:iam::aws:policy/AdministratorAccess'. Pass '--cloudformation-execution-policies' to customize.
CDKToolkit: creating CloudFormation changeset...
CDKToolkit: creating CloudFormation changeset...
:x:  Environment <aws://XXXXXXXXXX/eu-west-1> failed bootstrapping: ChangeSetNotFound: ChangeSet [CDK-bfda59d0-ce25-4f51-8706-xxxx] does not exist
at Request.extractError (/Users/pal/temp/simple-sst/node_modules/aws-sdk/lib/protocol/query.js:50:29)
at Request.callListeners (/Users/pal/temp/simple-sst/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/Users/pal/temp/simple-sst/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/Users/pal/temp/simple-sst/node_modules/aws-sdk/lib/request.js:688:14)
at Request.transition (/Users/pal/temp/simple-sst/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/Users/pal/temp/simple-sst/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /Users/pal/temp/simple-sst/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/Users/pal/temp/simple-sst/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/Users/pal/temp/simple-sst/node_modules/aws-sdk/lib/request.js:690:12)
at Request.callListeners (/Users/pal/temp/simple-sst/node_modules/aws-sdk/lib/sequential_executor.js:116:18) {
code: 'ChangeSetNotFound',
time: 2021-01-25T23:52:29.176Z,
requestId: 'dc3779dd-fff4-4371-9ca6-245a036d527d',
statusCode: 404,
retryable: false,
retryDelay: 115.1102715438432
}
:x:  test-supersimpletesttemp-peasy failed: ChangeSetNotFound: ChangeSet [CDK-bfda59d0-ce25-4f51-8706-xxxxx] does not exist
Stack test-supersimpletesttemp-peasy
Status: failed
Error: ChangeSet [CDK-bfda59d0-ce25-4f51-8706-xxxxxx] does not exist
I have never run cdk separately btw
But.. very weird. After this the CDKToolkit actually deployed OK, that hasn't been the case before
I also removed
"type": "@serverless-stack/resources",
from
sst.json
since I thought that was the problem
f
Hmmm.. which version of sst are you on? ie.
yarn sst --version
p
Copy code
❰pal❙~/temp/simple-sst❱00:53  ✔≻ aws-vault exec test-admin -- yarn sst start                                                                                                           00:53:30
yarn run v1.22.10
$ /Users/pal/temp/simple-sst/node_modules/.bin/sst start

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

 :hourglass_flowing_sand:  Bootstrapping environment <aws://XXXXXXXXXX/eu-west-1>...
Trusted accounts:   (none)
Using default execution policy of 'arn:aws:iam::aws:policy/AdministratorAccess'. Pass '--cloudformation-execution-policies' to customize.
CDKToolkit: creating CloudFormation changeset...
 :white_check_mark:  Environment <aws://XXXXXXXXXX/eu-west-1> bootstrapped (no changes).
test-supersimpletesttemp-debug-stack: deploying...
[0%] start: Publishing 5a07db3ec798475f65df916455e1273XXXXXXXXXX:current
[100%] success: Published 5a07db3ec798475f65df916455e1273XXXXXXXXXX:current
test-supersimpletesttemp-debug-stack: creating CloudFormation changeset...
[█████████▋················································] (4/24)

12:56:05 AM | CREATE_FAILED        | AWS::Lambda::Function          | Disconnect
Uploaded file must be a non-empty zip (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: d891c097-a2bd-4242-8201-XXXXXXXXXX1; Proxy: null
)
12:56:06 AM | ROLLBACK_IN_PROGRESS | AWS::CloudFormation::Stack     | test-supersimpletesttemp-debug-stack
The following resource(s) failed to create: [Disconnect7D6B12BD, Connect5B7625CA, Resource]. Rollback requested by user.












 :x:  test-supersimpletesttemp-debug-stack failed: Error: The stack named test-supersimpletesttemp-debug-stack failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE
    at Object.waitForStackDeploy (/Users/pal/temp/simple-sst/node_modules/sst-cdk/lib/api/util/cloudformation.ts:321:11)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at Object.deployStack (/Users/pal/temp/simple-sst/node_modules/sst-cdk/lib/api/deploy-stack.ts:348:26)
    at CdkToolkit.deploy (/Users/pal/temp/simple-sst/node_modules/sst-cdk/lib/cdk-toolkit.ts:194:24)
    at Object.deploy (/Users/pal/temp/simple-sst/node_modules/sst-cdk/lib/serverless-stack.ts:99:15)
    at Object.deploy (/Users/pal/temp/simple-sst/node_modules/@serverless-stack/core/index.js:25:10)
    at deploy (/Users/pal/temp/simple-sst/node_modules/@serverless-stack/cli/scripts/util/cdkHelpers.js:402:15)
    at deployDebugStack (/Users/pal/temp/simple-sst/node_modules/@serverless-stack/cli/scripts/start.js:128:21)
    at Object.module.exports [as start] (/Users/pal/temp/simple-sst/node_modules/@serverless-stack/cli/scripts/start.js:89:26)
Error: The stack named test-supersimpletesttemp-debug-stack failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE
    at Object.waitForStackDeploy (/Users/pal/temp/simple-sst/node_modules/sst-cdk/lib/api/util/cloudformation.ts:321:11)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at Object.deployStack (/Users/pal/temp/simple-sst/node_modules/sst-cdk/lib/api/deploy-stack.ts:348:26)
    at CdkToolkit.deploy (/Users/pal/temp/simple-sst/node_modules/sst-cdk/lib/cdk-toolkit.ts:194:24)
    at Object.deploy (/Users/pal/temp/simple-sst/node_modules/sst-cdk/lib/serverless-stack.ts:99:15)
    at Object.deploy (/Users/pal/temp/simple-sst/node_modules/@serverless-stack/core/index.js:25:10)
    at deploy (/Users/pal/temp/simple-sst/node_modules/@serverless-stack/cli/scripts/util/cdkHelpers.js:402:15)
    at deployDebugStack (/Users/pal/temp/simple-sst/node_modules/@serverless-stack/cli/scripts/start.js:128:21)
    at Object.module.exports [as start] (/Users/pal/temp/simple-sst/node_modules/@serverless-stack/cli/scripts/start.js:89:26)

Error: Failed to get the endpoint from the deployed debug stack test-supersimpletesttemp-debug-stack
    at deployDebugStack (/Users/pal/temp/simple-sst/node_modules/@serverless-stack/cli/scripts/start.js:142:11)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at Object.module.exports [as start] (/Users/pal/temp/simple-sst/node_modules/@serverless-stack/cli/scripts/start.js:89:26)

error Command failed with exit code 1.
info Visit <https://yarnpkg.com/en/docs/cli/run> for documentation about this command.
But after this successful (but error-producing) deploy, I get this:
SST: 0.6.2
f
hmm.. are you able to run it without aws-vault?
p
I can share the code in a repo if you want to try
sure, let me try that
I get
Uploaded file must be a non-empty zip
, but will empty the s3-bucket &
.build/
and try again
f
Yup
p
Still get that non-empty zip error.
and yet again ...
f
Yeah the error seems very strange.
It’d be helpful if you can share the code.
I will give it a try on my end.
p
third times the charm for a deploy! 🙂
That's quite weird. Deleted the stack, emptied the bucket and .build. Third try succeeded
Trying
start
now
f
Oh I see.
p
start failed with empty zip message, will create a repo now. REALLY appreciate you taking this time!
f
Nice!
Btw, jsut making sure you are also getting the same error for
sst start
for this repo?
p
yes, for start as well.
Worth mentioning is that I use
yarn
to run
f
got it. Trying it now
p
🙏
f
The app seem to run fine on my end.
But let’s double check a couple of things quickly.
Could you do a
ls -lsa node_modules/\@serverless-stack/cli/assets/debug-stack/lambda/
and paste the output here?
(run it at the sst app root)
p
Copy code
❰pal❙~/temp/simple-sst(gitmain)❱ 01:50 ✘≻ ls -lsa node_modules/\@serverless-stack/cli/assets/debug-stack/lambda/                                    01:50:15
total 32
 0 drwxr-xr-x 5 pal staff  160 Jan 25 22:24 ./
 0 drwxr-xr-x 7 pal staff  224 Jan 26 00:13 ../
 8 -rw-r--r-- 1 pal staff  88 Jan 25 21:53 wsConnect.js
16 -rw-r--r-- 1 pal staff 4582 Jan 25 21:53 wsDefault.js
 8 -rw-r--r-- 1 pal staff  91 Jan 25 21:53 wsDisconnect.js
f
I see.. so the Lambda files do exists..
We now jsut have to figure out why the zip is empty
ls -lsa node_modules/\@serverless-stack/cli/assets/debug-stack/cdk.out/
could you run this?
p
That's also weird. Because in .build it's not.
Copy code
total 192
 0 drwxr-xr-x 8 pal staff  256 Jan 26 00:54 ./
 0 drwxr-xr-x 7 pal staff  224 Jan 26 00:13 ../
 0 drwxr-xr-x 3 pal staff   96 Jan 26 00:54 .cache/
 0 drwxr-xr-x 5 pal staff  160 Jan 26 00:13 asset.5a07db3ec798475f65df916455e1273f5b751877099710e4d627b791fdb9acfd/
 8 -rw-r--r-- 1 pal staff   19 Jan 26 01:36 cdk.out
80 -rw-r--r-- 1 pal staff 39265 Jan 26 01:36 manifest.json
40 -rw-r--r-- 1 pal staff 19854 Jan 26 01:36 test-supersimpletesttemp-debug-stack.template.json
64 -rw-r--r-- 1 pal staff 32090 Jan 26 01:36 tree.json
f
ls -lsa node_modules/\@serverless-stack/cli/assets/debug-stack/cdk.out/asset.5a07db3ec798475f65df916455e1273f5b751877099710e4d627b791fdb9acfd/
One more
p
Copy code
❰pal❙~/temp/simple-sst(gitmain)❱ 01:53 ✔≻ find node_modules/\@serverless-stack/cli/assets/debug-stack/cdk.out/                                     01:53:12
node_modules/@serverless-stack/cli/assets/debug-stack/cdk.out/
node_modules/@serverless-stack/cli/assets/debug-stack/cdk.out//asset.5a07db3ec798475f65df916455e1273f5b751877099710e4d627b791fdb9acfd
node_modules/@serverless-stack/cli/assets/debug-stack/cdk.out//asset.5a07db3ec798475f65df916455e1273f5b751877099710e4d627b791fdb9acfd/wsDefault.js
node_modules/@serverless-stack/cli/assets/debug-stack/cdk.out//asset.5a07db3ec798475f65df916455e1273f5b751877099710e4d627b791fdb9acfd/wsDisconnect.js
node_modules/@serverless-stack/cli/assets/debug-stack/cdk.out//asset.5a07db3ec798475f65df916455e1273f5b751877099710e4d627b791fdb9acfd/wsConnect.js
node_modules/@serverless-stack/cli/assets/debug-stack/cdk.out//test-supersimpletesttemp-debug-stack.template.json
node_modules/@serverless-stack/cli/assets/debug-stack/cdk.out//manifest.json
node_modules/@serverless-stack/cli/assets/debug-stack/cdk.out//cdk.out
node_modules/@serverless-stack/cli/assets/debug-stack/cdk.out//.cache
node_modules/@serverless-stack/cli/assets/debug-stack/cdk.out//.cache/5a07db3ec798475f65df916455e1273f5b751877099710e4d627b791fdb9acfd.zip
node_modules/@serverless-stack/cli/assets/debug-stack/cdk.out//tree.json
yes, sorry bout that last one, figured you wanted to see all 🙂
Copy code
otal 32
 0 drwxr-xr-x 5 pal staff  160 Jan 26 00:13 ./
 0 drwxr-xr-x 8 pal staff  256 Jan 26 00:54 ../
 8 -rw-r--r-- 1 pal staff  88 Jan 26 00:13 wsConnect.js
16 -rw-r--r-- 1 pal staff 4582 Jan 26 00:13 wsDefault.js
 8 -rw-r--r-- 1 pal staff  91 Jan 26 00:13 wsDisconnect.js
f
Thanks Pal!
p
No worries! Did you get the same error?
My changes to
lib/index.js
seem OK?
f
node_modules/\@serverless-stack/cli/assets/debug-stack/cdk.out/test-supersimpletesttemp-debug-stack.template.json
Could you also send me this file?
sst start
worked fine on my side.
p
weird. Did you try using yarn as well? Or globally installed?
f
yeah I used yarn as well
Everything seem fine on your end as well so far.
Let me take a quick look at the CF template you sent over.
p
yeah, np
I also us
fish
shell, can try using
bash
, just to remove one factor
f
for sure that’d be great
And I see the IAM credential you are using to deploy has Admin Access right? I thikn that’s what I saw in the log
p
Yeah, should be admin access. I can double check. See this in console: Using default execution policy of 'arnawsiam:awspolicy/AdministratorAccess'. Pass '--cloudformation-execution-policies' to customize.
f
yeah
p
Yes,
AdministratorAccess
Same error with zip on bash. Will remove all assets in s3 and
.build
and try again
After a failed start, console says:
:x: *test-supersimpletesttemp-debug-stack* failed: Error: The stack named test-supersimpletesttemp-debug-stack failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE
I manually delete in these situations and try again
f
Do you also something like this above that error:
Copy code
test-supersimpletesttemp-debug-stack: creating CloudFormation changeset...
[█████████▋················································] (4/24)
12:56:05 AM | CREATE_FAILED        | AWS::Lambda::Function          | Disconnect
Uploaded file must be a non-empty zip (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: d891c097-a2bd-4242-8201-XXXXXXXXXX1; Proxy: null
)
12:56:06 AM | ROLLBACK_IN_PROGRESS | AWS::CloudFormation::Stack     | test-supersimpletesttemp-debug-stack
The following resource(s) failed to create: [Disconnect7D6B12BD, Connect5B7625CA, Resource]. Rollback requested by user.
p
Just to be clear on what I'm doing
Copy code
$ yarn sst start
yarn run v1.22.10
$ /Users/pal/temp/sst-eu-example/node_modules/.bin/sst start

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

 :hourglass_flowing_sand:  Bootstrapping environment <aws://xxxxxxxx/eu-west-1>...
Trusted accounts:   (none)
Using default execution policy of 'arn:aws:iam::aws:policy/AdministratorAccess'. Pass '--cloudformation-execution-policies' to customize.
CDKToolkit: creating CloudFormation changeset...
 :white_check_mark:  Environment <aws://xxxxxxxx/eu-west-1> bootstrapped (no changes).
test-supersimpletesttemp-debug-stack: deploying...
[0%] start: Publishing 5a07db3ec798475f65df916455e1273f5b751877099710e4d627b791fdb9acfd:current
[100%] success: Published 5a07db3ec798475f65df916455e1273f5b751877099710e4d627b791fdb9acfd:current
test-supersimpletesttemp-debug-stack: creating CloudFormation changeset...
[█████████▋················································] (4/24)

2:00:23 AM | CREATE_FAILED        | AWS::Lambda::Function          | Disconnect
Uploaded file must be a non-empty zip (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: 8740714a-17fd-4b9f-b8f3-c4f791b088ef; Proxy: null
)
2:00:24 AM | ROLLBACK_IN_PROGRESS | AWS::CloudFormation::Stack     | test-supersimpletesttemp-debug-stack
The following resource(s) failed to create: [Disconnect7D6B12BD, Connect5B7625CA, Resource]. Rollback requested by user.












 :x:  test-supersimpletesttemp-debug-stack failed: Error: The stack named test-supersimpletesttemp-debug-stack failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE
    at Object.waitForStackDeploy (/Users/pal/temp/sst-eu-example/node_modules/sst-cdk/lib/api/util/cloudformation.ts:321:11)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at Object.deployStack (/Users/pal/temp/sst-eu-example/node_modules/sst-cdk/lib/api/deploy-stack.ts:348:26)
    at CdkToolkit.deploy (/Users/pal/temp/sst-eu-example/node_modules/sst-cdk/lib/cdk-toolkit.ts:194:24)
    at Object.deploy (/Users/pal/temp/sst-eu-example/node_modules/sst-cdk/lib/serverless-stack.ts:99:15)
    at Object.deploy (/Users/pal/temp/sst-eu-example/node_modules/@serverless-stack/core/index.js:25:10)
    at deploy (/Users/pal/temp/sst-eu-example/node_modules/@serverless-stack/cli/scripts/util/cdkHelpers.js:402:15)
    at deployDebugStack (/Users/pal/temp/sst-eu-example/node_modules/@serverless-stack/cli/scripts/start.js:128:21)
    at Object.module.exports [as start] (/Users/pal/temp/sst-eu-example/node_modules/@serverless-stack/cli/scripts/start.js:89:26)
Error: The stack named test-supersimpletesttemp-debug-stack failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE
    at Object.waitForStackDeploy (/Users/pal/temp/sst-eu-example/node_modules/sst-cdk/lib/api/util/cloudformation.ts:321:11)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at Object.deployStack (/Users/pal/temp/sst-eu-example/node_modules/sst-cdk/lib/api/deploy-stack.ts:348:26)
    at CdkToolkit.deploy (/Users/pal/temp/sst-eu-example/node_modules/sst-cdk/lib/cdk-toolkit.ts:194:24)
    at Object.deploy (/Users/pal/temp/sst-eu-example/node_modules/sst-cdk/lib/serverless-stack.ts:99:15)
    at Object.deploy (/Users/pal/temp/sst-eu-example/node_modules/@serverless-stack/core/index.js:25:10)
    at deploy (/Users/pal/temp/sst-eu-example/node_modules/@serverless-stack/cli/scripts/util/cdkHelpers.js:402:15)
    at deployDebugStack (/Users/pal/temp/sst-eu-example/node_modules/@serverless-stack/cli/scripts/start.js:128:21)
    at Object.module.exports [as start] (/Users/pal/temp/sst-eu-example/node_modules/@serverless-stack/cli/scripts/start.js:89:26)

Error: Failed to get the endpoint from the deployed debug stack test-supersimpletesttemp-debug-stack
    at deployDebugStack (/Users/pal/temp/sst-eu-example/node_modules/@serverless-stack/cli/scripts/start.js:142:11)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at Object.module.exports [as start] (/Users/pal/temp/sst-eu-example/node_modules/@serverless-stack/cli/scripts/start.js:89:26)

error Command failed with exit code 1.
info Visit <https://yarnpkg.com/en/docs/cli/run> for documentation about this command.
f
Yup.. so adding some context.
sst start
is failing to deploy the debug stack right now. The debug stack is the one that has a websocket server that communicates between ur Lambda on AWS and the Lambda code on your local.
The debug stack deploys 3 lambda functions, wsConnect, wsDisconnect and wsDefault.
So far, we have verified that you have all 3 lambda functions.
We have also verified that all 3 lambda functions are picked up by CDK, and are placed in the asset folder to be zipped up and uploaded.
p
I see. So, when I check in the s3 bucket
cdk-hnb659fds-assets-XXXXX-eu-west-1
I find the zip-file under
assets/
f
I see. What’s in there?
p
These 3 files, which seems correct I think?
f
You see a
5a07db3ec798475f65df916455e1273f5b751877099710e4d627b791fdb9acfd.zip
file with 1.9KB in size, and after u unzip it, u see these 3 files. Right?
p
Yes
f
hmm that looks right as well.
Lemme think what else can be different.
Let’s check the CF template and see if it’s referencing the correct zip file in the correct S3 bucket.
p
roger!
f
If you go into ur CF console, do you see a
test-supersimpletesttemp-debug-stack
stack?
perhaps in ROLLBACK_COMPLETE state
p
Yeah.
f
Can you click in and see what it shows in the Parameters tab?
p
assets/||5a07db3ec798475f65df916455e1273f5b751877099710e4d627b791fdb9acfd.zip
For
AssetParameters5a07db3ec798475f65df916455e1273f5b751877099710e4d627b791fdb9acfdS3VersionKey580C0063
The 2 pipes there, is that normal?
f
yeah I have that too in mine
p
Nothing in resolved value
f
yup
that looks exactly the same
I can think of one last thing to double check
CloudTrail should’ve logged the API call CF made to Lambda to create the function, and that API call failed for you with the error:
Copy code
Uploaded file must be a non-empty zip (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: 8740714a-17fd-4b9f-b8f3-c4f791b088ef; Proxy: null
)
We should be able to see the exact request with full request params CF made.
p
Just to be sure, running
deploy
doesn't affect the
debug
stack, right? because
deploy
goes through
f
Correct
sst deploy
deploys your actual Lambda function.
sst start
deploys the debug stack first, it then deploys your app with all your Lambda functions swapped with stub code that talks to your local.
p
yeah. even though that is also spotty unfortunately, giving zip-problems as well
f
It seems CDK zipped it fine; and uploaded to S3 fine; and updated the CF template with the correct S3 file path
I hope CloudTrail helps reveal the actually error
p
Any idea what I should look for?
f
If you go into your CloudTrail console, and click on Event history
Look for the most recent event with name starting
CreateFunction
p
Copy code
{
  "eventVersion": "1.08",
  "userIdentity": {
    "type": "IAMUser",
    "principalId": "AIDAQZBAEH36RMZZF455O",
    "arn": "arn:aws:iam::053754478333:user/pal-mbp",
    "accountId": "053754478333",
    "accessKeyId": "ASIAJBFWIDKLWD3GKZWQ",
    "userName": "pal-mbp",
    "sessionContext": {
      "sessionIssuer": {},
      "webIdFederationData": {},
      "attributes": {
        "mfaAuthenticated": "false",
        "creationDate": "2021-01-26T00:59:01Z"
      }
    },
    "invokedBy": "<http://cloudformation.amazonaws.com|cloudformation.amazonaws.com>"
  },
  "eventTime": "2021-01-26T01:00:23Z",
  "eventSource": "<http://lambda.amazonaws.com|lambda.amazonaws.com>",
  "eventName": "CreateFunction20150331",
  "awsRegion": "eu-west-1",
  "sourceIPAddress": "<http://cloudformation.amazonaws.com|cloudformation.amazonaws.com>",
  "userAgent": "<http://cloudformation.amazonaws.com|cloudformation.amazonaws.com>",
  "errorCode": "InvalidParameterValueException",
  "errorMessage": "Uploaded file must be a non-empty zip",
  "requestParameters": {
    "functionName": "test-supersimpletesttemp-debug-Disconnect7D6B12BD-MN4MQRGX4FKL",
    "runtime": "nodejs12.x",
    "role": "arn:aws:iam::053754478333:role/test-supersimpletesttemp-DisconnectServiceRole90A-10Y6GCCW63TQW",
    "handler": "wsDisconnect.main",
    "code": {
      "s3Bucket": "cdk-hnb659fds-assets-053754478333-eu-west-1",
      "s3Key": "assets/5a07db3ec798475f65df916455e1273f5b751877099710e4d627b791fdb9acfd.zip"
    },
    "description": "",
    "timeout": 10,
    "memorySize": 256,
    "publish": false,
    "environment": {},
    "tags": {
      "aws:cloudformation:stack-name": "test-supersimpletesttemp-debug-stack",
      "aws:cloudformation:stack-id": "arn:aws:cloudformation:eu-west-1:053754478333:stack/test-supersimpletesttemp-debug-stack/aa5ac270-5f71-11eb-b58c-0ad9a0231ad1",
      "aws:cloudformation:logical-id": "Disconnect7D6B12BD"
    },
    "fileSystemConfigs": []
  },
  "responseElements": null,
  "requestID": "8740714a-17fd-4b9f-b8f3-c4f791b088ef",
  "eventID": "75c93436-7f76-43f4-bae3-9a2f227dcdb4",
  "readOnly": false,
  "eventType": "AwsApiCall",
  "managementEvent": true,
  "eventCategory": "Management",
  "recipientAccountId": "053754478333"
}
f
let me see..
p
I just ran it again and it's just a single such event now:
Copy code
{
  "eventVersion": "1.08",
  "userIdentity": {
    "type": "IAMUser",
    "principalId": "AIDAQZBAEH36RMZZF455O",
    "arn": "arn:aws:iam::053754478333:user/pal-mbp",
    "accountId": "053754478333",
    "accessKeyId": "ASIAIV7X4WZG4VGDL5RA",
    "userName": "pal-mbp",
    "sessionContext": {
      "sessionIssuer": {},
      "webIdFederationData": {},
      "attributes": {
        "mfaAuthenticated": "false",
        "creationDate": "2021-01-26T01:19:03Z"
      }
    },
    "invokedBy": "<http://cloudformation.amazonaws.com|cloudformation.amazonaws.com>"
  },
  "eventTime": "2021-01-26T01:19:57Z",
  "eventSource": "<http://lambda.amazonaws.com|lambda.amazonaws.com>",
  "eventName": "CreateFunction20150331",
  "awsRegion": "eu-west-1",
  "sourceIPAddress": "<http://cloudformation.amazonaws.com|cloudformation.amazonaws.com>",
  "userAgent": "<http://cloudformation.amazonaws.com|cloudformation.amazonaws.com>",
  "requestParameters": {
    "functionName": "test-supersimpletesttemp-supersimpl-LambdaD247545B-ZZ7J8GLGCRBJ",
    "runtime": "nodejs12.x",
    "role": "arn:aws:iam::053754478333:role/test-supersimpletesttemp-LambdaServiceRoleA8ED4D3-1XP73PAWH4ZGF",
    "handler": "src/lambda.handler",
    "code": {
      "s3Bucket": "cdk-hnb659fds-assets-053754478333-eu-west-1",
      "s3Key": "assets/25e6d9ad99e58f0a4839bafb93bb40c7ba2301fca03e67373b5380b022f7fb0b.zip"
    },
    "description": "",
    "timeout": 3,
    "memorySize": 128,
    "publish": false,
    "environment": {},
    "tags": {
      "aws:cloudformation:stack-name": "test-supersimpletesttemp-supersimpletesttemp",
      "aws:cloudformation:stack-id": "arn:aws:cloudformation:eu-west-1:053754478333:stack/test-supersimpletesttemp-supersimpletesttemp/79f31170-5f74-11eb-9737-02490df7d905",
      "aws:cloudformation:logical-id": "LambdaD247545B"
    },
    "fileSystemConfigs": []
  },
  "responseElements": {
    "functionName": "test-supersimpletesttemp-supersimpl-LambdaD247545B-ZZ7J8GLGCRBJ",
    "functionArn": "arn:aws:lambda:eu-west-1:053754478333:function:test-supersimpletesttemp-supersimpl-LambdaD247545B-ZZ7J8GLGCRBJ",
    "runtime": "nodejs12.x",
    "role": "arn:aws:iam::053754478333:role/test-supersimpletesttemp-LambdaServiceRoleA8ED4D3-1XP73PAWH4ZGF",
    "handler": "src/lambda.handler",
    "codeSize": 5167,
    "description": "",
    "timeout": 3,
    "memorySize": 128,
    "lastModified": "2021-01-26T01:19:57.224+0000",
    "codeSha256": "rRjaOKsLsVNzfL8nKjtFqZ6X9F7Vs3oxBFBY7GKolfY=",
    "version": "$LATEST",
    "environment": {},
    "tracingConfig": {
      "mode": "PassThrough"
    },
    "revisionId": "95006900-f10d-46f4-bc88-949f84af5891",
    "state": "Active",
    "lastUpdateStatus": "Successful",
    "packageType": "Zip"
  },
  "requestID": "4978c811-d163-40bf-91bf-cc176d371713",
  "eventID": "9de94cae-ef90-4841-9c9d-b3aa5e9c2c29",
  "readOnly": false,
  "eventType": "AwsApiCall",
  "managementEvent": true,
  "eventCategory": "Management",
  "recipientAccountId": "053754478333"
}
f
Oh re-running it worked?
p
no, failed in same way
But I see the timestamps are not what I expect in CloudTrail
Hope I sent you the right one...
Seems a bit laggy
Many rows...
f
hmm yeah.. could u send me the most recent one at 022622 just to confirm it’s all the same error
p
Copy code
{
  "eventVersion": "1.08",
  "userIdentity": {
    "type": "IAMUser",
    "principalId": "AIDAQZBAEH36RMZZF455O",
    "arn": "arn:aws:iam::053754478333:user/pal-mbp",
    "accountId": "053754478333",
    "accessKeyId": "ASIAJHCGZ5LQQB6K6JWA",
    "userName": "pal-mbp",
    "sessionContext": {
      "sessionIssuer": {},
      "webIdFederationData": {},
      "attributes": {
        "mfaAuthenticated": "false",
        "creationDate": "2021-01-26T01:25:10Z"
      }
    },
    "invokedBy": "<http://cloudformation.amazonaws.com|cloudformation.amazonaws.com>"
  },
  "eventTime": "2021-01-26T01:26:22Z",
  "eventSource": "<http://lambda.amazonaws.com|lambda.amazonaws.com>",
  "eventName": "CreateFunction20150331",
  "awsRegion": "eu-west-1",
  "sourceIPAddress": "<http://cloudformation.amazonaws.com|cloudformation.amazonaws.com>",
  "userAgent": "<http://cloudformation.amazonaws.com|cloudformation.amazonaws.com>",
  "errorCode": "InvalidParameterValueException",
  "errorMessage": "Uploaded file must be a non-empty zip",
  "requestParameters": {
    "functionName": "test-supersimpletesttemp-debug-sta-Connect5B7625CA-6VN6HFEKZ4C1",
    "runtime": "nodejs12.x",
    "role": "arn:aws:iam::053754478333:role/test-supersimpletesttemp-ConnectServiceRole07B61C-1I3EK891BQPGH",
    "handler": "wsConnect.main",
    "code": {
      "s3Bucket": "cdk-hnb659fds-assets-053754478333-eu-west-1",
      "s3Key": "assets/5a07db3ec798475f65df916455e1273f5b751877099710e4d627b791fdb9acfd.zip"
    },
    "description": "",
    "timeout": 10,
    "memorySize": 256,
    "publish": false,
    "environment": {},
    "tags": {
      "aws:cloudformation:stack-name": "test-supersimpletesttemp-debug-stack",
      "aws:cloudformation:stack-id": "arn:aws:cloudformation:eu-west-1:053754478333:stack/test-supersimpletesttemp-debug-stack/4ea6f8f0-5f75-11eb-9c99-021bac0dff71",
      "aws:cloudformation:logical-id": "Connect5B7625CA"
    },
    "fileSystemConfigs": []
  },
  "responseElements": null,
  "requestID": "210c3917-f9d9-4a7e-a6bb-f55ca8ac20d7",
  "eventID": "0eb85664-a0c5-428b-92e1-bde7aab9a8c9",
  "readOnly": false,
  "eventType": "AwsApiCall",
  "managementEvent": true,
  "eventCategory": "Management",
  "recipientAccountId": "053754478333"
}
btw, I really appreciate you taking this time! Amazingly good of you!
f
Nah for sure! I want to figure out the root cause, and get the team to push out an update for this.
p
I'll restart my computer. Need to feel I've tried everything 😄
brb
f
p
reading through it now, I saw it earlier, but more details now!
Hey! After clearing out the bucket and the
.build
dir, it worked! 😄
f
Oh Nice! Was pinning the archiver version required?
p
Goddam. Sent you on a wild goose chase for this. I saw that issue earlier, but at that point the fix with archiver wasn't in
Yeah. I also downgraded node, but can revert that to be sure!
f
Oh man.. I’m glad u finally got it to work!
p
Indeed! Now to extract and deploy a 'real' function! 🙂
f
Awesome!
p
HUGE THANKS for your patience in helping me find this! I'm 100% sure you had other plans, but shifted them to help me out, I'm really happy for that!
Anything I can do to help you out?
f
Yeah we are planning to put together ways for folks to migrate to SST. If there’s anything that come up, or thing u’d like to see that help with the migration, I’m all ears!
p
I'll make sure to keep some notes on things that got me stumbling etc! On that note, i currently have a bunch of stacks in sls. Do you think it makes sense to migrate to SST/CDK for a project with ~70 functions in 17 stacks? And if so, would you recommend sticking to small-ish stacks?
Actually, let me post that as a new question - makes it easier for other folks to find it!
Thanks again Frank! 🙏
f
Any time! 👍
p
Note to future readers: Using
aws-vault
made this error reappear. I had to make sure all my profiles in
~/.aws/config
explicitly set
region=eu-west-1
. See https://github.com/aws/aws-cdk/issues/1656