Link to chapter — https://serverless-stack.com/chapters/create-an-sst-app.html
Hello,
When I run the following command to create an SST app:
$ npx create-serverless-stack@latest notes
$ cd notes
The sst.json
file looks different than what is shown in the page.
This is what the page shows:
{
"name": "notes",
"stage": "dev",
"region": "us-east-1",
"lint": true
}
And this is the sst.json
that was created:
{
"name": "notes",
"region": "us-east-1",
"main": "stacks/index.js"
}
I edited sst.json
as follows:
{
"name": "notes",
"stage": "dev",
"region": "eu-central-1",
"main": "stacks/index.js"
}
And then I ran npx sst start
. When I navigate to the CloudFormation Console, I see that there are two stacks created:
- dev-notes-my-stack
- dev-notes-debug-stack
Is this the expected behavior? It seems like from the guide, and the command name itself (i.e.start
) that it should only start locally, but not actually deploy.
I’m also confused as to why it created to stacks instead of just one.
Here is the CloudFormation console showing the created stacks after running npx sst start
:
Here’s the terminal output after running npx sst start
, and visiting the endpoint once:
(P.S I substituted my actual account ID with accountID
)
Warning: Setting the stage in the "sst.json" will be deprecated soon. Read more about this change here: https://docs.serverless-stack.com/working-locally#deprecating-the-stage-option-in-the-sstjson
Using stage: dev
Preparing your SST app
Transpiling source
Linting source
=======================
Deploying debug stack
=======================
Deploying stacks
CDK_NEW_BOOTSTRAP set, using new-style bootstrapping
⏳ Bootstrapping environment aws://accountID/eu-central-1...
Trusted accounts for deployment: (none)
Trusted accounts for lookup: (none)
Using default execution policy of 'arn:aws:iam::aws:policy/AdministratorAccess'. Pass '--cloudformation-execution-policies' to customize.
CDKToolkit: creating CloudFormation changeset...
✅ Environment aws://accountID/eu-central-1 bootstrapped.
Checking deploy status...
Checking deploy status...
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::CloudFormation::Stack | dev-notes-debug-stack
Checking deploy status...
Checking deploy status...
Checking deploy status...
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::ApiGatewayV2::Api | Api
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::IAM::Role | ServiceRole4288B192
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::DynamoDB::Table | TableCD117FA1
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::S3::Bucket | Bucket83908E77
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::IAM::Role | CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::DynamoDB::Table | TableCD117FA1
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::IAM::Role | ServiceRole4288B192
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::IAM::Role | DisconnectServiceRole90AEC2EB
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::IAM::Role | ConnectServiceRole07B61CE8
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::IAM::Role | CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::IAM::Role | DisconnectServiceRole90AEC2EB
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::S3::Bucket | Bucket83908E77
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::IAM::Role | ConnectServiceRole07B61CE8
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::ApiGatewayV2::Api | Api
dev-notes-debug-stack | CREATE_COMPLETE | AWS::ApiGatewayV2::Api | Api
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::ApiGatewayV2::Stage | ApiStage
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::ApiGatewayV2::Stage | ApiStage
dev-notes-debug-stack | CREATE_COMPLETE | AWS::ApiGatewayV2::Stage | ApiStage
Checking deploy status...
dev-notes-debug-stack | CREATE_COMPLETE | AWS::IAM::Role | ServiceRole4288B192
dev-notes-debug-stack | CREATE_COMPLETE | AWS::IAM::Role | CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092
dev-notes-debug-stack | CREATE_COMPLETE | AWS::IAM::Role | DisconnectServiceRole90AEC2EB
dev-notes-debug-stack | CREATE_COMPLETE | AWS::IAM::Role | ConnectServiceRole07B61CE8
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::IAM::Policy | ServiceRoleDefaultPolicy94CF55F6
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::IAM::Policy | DisconnectServiceRoleDefaultPolicy32856207
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::IAM::Policy | ConnectServiceRoleDefaultPolicyCE008EDB
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::IAM::Policy | ServiceRoleDefaultPolicy94CF55F6
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::IAM::Policy | DisconnectServiceRoleDefaultPolicy32856207
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::IAM::Policy | ConnectServiceRoleDefaultPolicyCE008EDB
dev-notes-debug-stack | CREATE_COMPLETE | AWS::S3::Bucket | Bucket83908E77
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::Lambda::Function | CustomS3AutoDeleteObjectsCustomResourceProviderHandler9D90184F
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::S3::BucketPolicy | BucketPolicyE9A3008A
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::S3::BucketPolicy | BucketPolicyE9A3008A
dev-notes-debug-stack | CREATE_COMPLETE | AWS::S3::BucketPolicy | BucketPolicyE9A3008A
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::Lambda::Function | CustomS3AutoDeleteObjectsCustomResourceProviderHandler9D90184F
dev-notes-debug-stack | CREATE_COMPLETE | AWS::Lambda::Function | CustomS3AutoDeleteObjectsCustomResourceProviderHandler9D90184F
dev-notes-debug-stack | CREATE_IN_PROGRESS | Custom::S3AutoDeleteObjects | BucketAutoDeleteObjectsCustomResourceBAFD23C2
dev-notes-debug-stack | CREATE_COMPLETE | AWS::DynamoDB::Table | TableCD117FA1
dev-notes-debug-stack | CREATE_COMPLETE | AWS::IAM::Policy | ServiceRoleDefaultPolicy94CF55F6
dev-notes-debug-stack | CREATE_COMPLETE | AWS::IAM::Policy | DisconnectServiceRoleDefaultPolicy32856207
dev-notes-debug-stack | CREATE_COMPLETE | AWS::IAM::Policy | ConnectServiceRoleDefaultPolicyCE008EDB
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::Lambda::Function | Resource
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::Lambda::Function | Disconnect7D6B12BD
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::Lambda::Function | Connect5B7625CA
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::Lambda::Function | Resource
dev-notes-debug-stack | CREATE_COMPLETE | AWS::Lambda::Function | Resource
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::Lambda::Function | Disconnect7D6B12BD
dev-notes-debug-stack | CREATE_IN_PROGRESS | Custom::S3AutoDeleteObjects | BucketAutoDeleteObjectsCustomResourceBAFD23C2
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::Lambda::Function | Connect5B7625CA
dev-notes-debug-stack | CREATE_COMPLETE | Custom::S3AutoDeleteObjects | BucketAutoDeleteObjectsCustomResourceBAFD23C2
dev-notes-debug-stack | CREATE_COMPLETE | AWS::Lambda::Function | Disconnect7D6B12BD
dev-notes-debug-stack | CREATE_COMPLETE | AWS::Lambda::Function | Connect5B7625CA
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::ApiGatewayV2::Integration | DefaultIntegration
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::Lambda::Permission | DefaultPermission
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::Lambda::Permission | DefaultPermission
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::ApiGatewayV2::Integration | DefaultIntegration
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::ApiGatewayV2::Integration | ConnectIntegration
dev-notes-debug-stack | CREATE_COMPLETE | AWS::ApiGatewayV2::Integration | DefaultIntegration
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::ApiGatewayV2::Integration | DisconnectIntegration
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::Lambda::Permission | DisconnectDisconnectPermission933E876E
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::Lambda::Permission | ConnectConnectPermission9DBC7813
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::Lambda::Permission | ConnectConnectPermission9DBC7813
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::Lambda::Permission | DisconnectDisconnectPermission933E876E
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::ApiGatewayV2::Integration | ConnectIntegration
dev-notes-debug-stack | CREATE_COMPLETE | AWS::ApiGatewayV2::Integration | ConnectIntegration
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::ApiGatewayV2::Integration | DisconnectIntegration
dev-notes-debug-stack | CREATE_COMPLETE | AWS::ApiGatewayV2::Integration | DisconnectIntegration
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::ApiGatewayV2::Route | DefaultRoute
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::ApiGatewayV2::Route | ConnectRoute
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::ApiGatewayV2::Route | DefaultRoute
dev-notes-debug-stack | CREATE_COMPLETE | AWS::ApiGatewayV2::Route | DefaultRoute
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::ApiGatewayV2::Route | DisconnectRoute
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::ApiGatewayV2::Route | DisconnectRoute
dev-notes-debug-stack | CREATE_COMPLETE | AWS::ApiGatewayV2::Route | DisconnectRoute
dev-notes-debug-stack | CREATE_IN_PROGRESS | AWS::ApiGatewayV2::Route | ConnectRoute
dev-notes-debug-stack | CREATE_COMPLETE | AWS::ApiGatewayV2::Route | ConnectRoute
dev-notes-debug-stack | CREATE_COMPLETE | AWS::Lambda::Permission | DefaultPermission
dev-notes-debug-stack | CREATE_COMPLETE | AWS::Lambda::Permission | ConnectConnectPermission9DBC7813
dev-notes-debug-stack | CREATE_COMPLETE | AWS::Lambda::Permission | DisconnectDisconnectPermission933E876E
dev-notes-debug-stack | CREATE_COMPLETE | AWS::CloudFormation::Stack | dev-notes-debug-stack
✅ dev-notes-debug-stack
Stack dev-notes-debug-stack
Status: deployed
Outputs:
BucketArn: arn:aws:s3:::dev-notes-debug-stack-bucket83908e77-1u31iqt4zzmwn
BucketName: dev-notes-debug-stack-bucket83908e77-1u31iqt4zzmwn
Endpoint: wss://cpzercu4sd.execute-api.eu-central-1.amazonaws.com/dev
===============
Deploying app
===============
Deploying stacks
Checking deploy status...
dev-notes-my-stack | CREATE_IN_PROGRESS | AWS::CloudFormation::Stack | dev-notes-my-stack
Checking deploy status...
Checking deploy status...
Checking deploy status...
dev-notes-my-stack | CREATE_IN_PROGRESS | AWS::IAM::Role | ApiLambdaGETServiceRole210B6205
dev-notes-my-stack | CREATE_IN_PROGRESS | AWS::CDK::Metadata | SSTMetadata
dev-notes-my-stack | CREATE_IN_PROGRESS | AWS::ApiGatewayV2::Api | ApiCD79AAA0
dev-notes-my-stack | CREATE_IN_PROGRESS | AWS::IAM::Role | ApiLambdaGETServiceRole210B6205
dev-notes-my-stack | CREATE_IN_PROGRESS | AWS::CDK::Metadata | SSTMetadata
dev-notes-my-stack | CREATE_IN_PROGRESS | AWS::ApiGatewayV2::Api | ApiCD79AAA0
dev-notes-my-stack | CREATE_COMPLETE | AWS::CDK::Metadata | SSTMetadata
dev-notes-my-stack | CREATE_COMPLETE | AWS::ApiGatewayV2::Api | ApiCD79AAA0
dev-notes-my-stack | CREATE_IN_PROGRESS | AWS::Logs::LogGroup | ApiLogGroup1717FE17
dev-notes-my-stack | CREATE_IN_PROGRESS | AWS::Logs::LogGroup | ApiLogGroup1717FE17
dev-notes-my-stack | CREATE_COMPLETE | AWS::Logs::LogGroup | ApiLogGroup1717FE17
dev-notes-my-stack | CREATE_IN_PROGRESS | AWS::ApiGatewayV2::Stage | ApiDefaultStage1AAE989B
dev-notes-my-stack | CREATE_IN_PROGRESS | AWS::ApiGatewayV2::Stage | ApiDefaultStage1AAE989B
dev-notes-my-stack | CREATE_COMPLETE | AWS::ApiGatewayV2::Stage | ApiDefaultStage1AAE989B
Checking deploy status...
dev-notes-my-stack | CREATE_COMPLETE | AWS::IAM::Role | ApiLambdaGETServiceRole210B6205
dev-notes-my-stack | CREATE_IN_PROGRESS | AWS::IAM::Policy | ApiLambdaGETServiceRoleDefaultPolicy013A8DEA
dev-notes-my-stack | CREATE_IN_PROGRESS | AWS::IAM::Policy | ApiLambdaGETServiceRoleDefaultPolicy013A8DEA
Checking deploy status...
dev-notes-my-stack | CREATE_COMPLETE | AWS::IAM::Policy | ApiLambdaGETServiceRoleDefaultPolicy013A8DEA
dev-notes-my-stack | CREATE_IN_PROGRESS | AWS::Lambda::Function | ApiLambdaGETB1714EF3
dev-notes-my-stack | CREATE_IN_PROGRESS | AWS::Lambda::Function | ApiLambdaGETB1714EF3
dev-notes-my-stack | CREATE_COMPLETE | AWS::Lambda::Function | ApiLambdaGETB1714EF3
dev-notes-my-stack | CREATE_IN_PROGRESS | AWS::Lambda::EventInvokeConfig | ApiLambdaGETEventInvokeConfig1B7345F6
dev-notes-my-stack | CREATE_IN_PROGRESS | AWS::Lambda::Permission | ApiRouteGETdevnotesmystackApiRouteGET21006C5EPermissionA482583E
dev-notes-my-stack | CREATE_IN_PROGRESS | AWS::ApiGatewayV2::Integration | ApiRouteGETHttpIntegration21fa5f74f1a9ce06757310bdc473058a6E5ECB5F
dev-notes-my-stack | CREATE_IN_PROGRESS | AWS::Lambda::Permission | ApiRouteGETdevnotesmystackApiRouteGET21006C5EPermissionA482583E
dev-notes-my-stack | CREATE_IN_PROGRESS | AWS::ApiGatewayV2::Integration | ApiRouteGETHttpIntegration21fa5f74f1a9ce06757310bdc473058a6E5ECB5F
dev-notes-my-stack | CREATE_COMPLETE | AWS::ApiGatewayV2::Integration | ApiRouteGETHttpIntegration21fa5f74f1a9ce06757310bdc473058a6E5ECB5F
dev-notes-my-stack | CREATE_IN_PROGRESS | AWS::Lambda::EventInvokeConfig | ApiLambdaGETEventInvokeConfig1B7345F6
dev-notes-my-stack | CREATE_COMPLETE | AWS::Lambda::EventInvokeConfig | ApiLambdaGETEventInvokeConfig1B7345F6
dev-notes-my-stack | CREATE_IN_PROGRESS | AWS::ApiGatewayV2::Route | ApiRouteGET8AC7D3F8
dev-notes-my-stack | CREATE_IN_PROGRESS | AWS::ApiGatewayV2::Route | ApiRouteGET8AC7D3F8
dev-notes-my-stack | CREATE_COMPLETE | AWS::ApiGatewayV2::Route | ApiRouteGET8AC7D3F8
Checking deploy status...
dev-notes-my-stack | CREATE_COMPLETE | AWS::Lambda::Permission | ApiRouteGETdevnotesmystackApiRouteGET21006C5EPermissionA482583E
dev-notes-my-stack | CREATE_COMPLETE | AWS::CloudFormation::Stack | dev-notes-my-stack
✅ dev-notes-my-stack
Stack dev-notes-my-stack
Status: deployed
Outputs:
ApiEndpoint: https://eb4pxg2kyg.execute-api.eu-central-1.amazonaws.com
==========================
Starting Live Lambda Dev
==========================
Transpiling Lambda code...
Debug session started. Listening for requests...
737fac34-4341-477e-a0c7-8a511e8d97cb REQUEST dev-notes-my-stack-ApiLambdaGETB1714EF3-hglvcqBoj6zs [src/lambda.handler] invoked by API GET /
737fac34-4341-477e-a0c7-8a511e8d97cb RESPONSE {"statusCode":200,"headers":{"Content-Type":"text/plain"},"body":"Hello, World! Your request was received at 16/Oct/2021:19:58:49 +0000."}
Yeah this gets mentioned later (Create a Hello World API) that sst start
deploys a debug stack. You might’ve figured this out already but the key aspect of the local development environment is that it is allowing you to test resources that’ve been deployed to AWS.
For the sst.json
, we had an update recently that removes the stage
option from it. I’ll edit the chapter to reflect that.
Hello inside src there is a lambda function in file lambda.js … What if I want to create a python lambda function if I keep .py script instead of lambda.js will it work?
Yeah here’s a Python example: serverless-stack/examples/rest-api-python at master · serverless-stack/serverless-stack · GitHub
Hi
I am getting below error on windows 11 node version 16
c2f0e166-1148-4b5f-9b2c-a9f4360cf770 REQUEST serverless-notes-my-stack-ApiLambdaGETB1714EF3-Q6Mn4GH2fIvJ [src/lambda.handler] invoked by API GET /
Unhandled Promise Rejection {“errorType”:“Runtime.UnhandledPromiseRejection”,“errorMessage”:“Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol ‘c:’”,“reason”:“Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol ‘c:’”,“promise”:{},“stack”:[“Runtime.UnhandledPromiseRejection: Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol ‘c:’”," at process. (file:///C:/Users/Ganesh~1Shinde/notes/node_modules/@serverless-stack/aws-lambda-ric/lib/index.js:34:23)"," at process.emit (node:events:390:28)"," at emit (node:internal/process/promises:136:22)"," at processPromiseRejections (node:internal/process/promises:242:25)"," at processTicksAndRejections (node:internal/process/task_queues:97:32)"]}
Hello I have double checked everything but get the following errors. I had successfully set up everything on another intel MacBook before moving to M1 pro machine.
Hmm that’s strange. Can you hop on to our Slack and post about this? https://serverless-stack.com/slack
hi, when I run:
npm init sst javascript-starter notes
it generated a new folder javascript-starter
instead of notes
, there was also no stacks/MyStack.js
like the one on the next chapter on the guide
is there anything I missed? thank you
Hey @Barbariansyah, we made some changes to how an SST app is bootstrapped yester, and the above command no longer works.
I just updated the guide to use the new command:
npx create-sst@latest --template=starters/javascript-starter notes
Give it a try! Sorry about the confusion.
Your doco is inconsistent:
Create an SST app asks me to use pnpm
but the correct doco on Create a Standalone SST App | SST offers npx
Two problems I suggest fixing?
- Why on Earth would I bother to install pnpm?
- Why are the docos out of sync?