Getting Production Ready
Now that we’ve gone through the basics of creating a full-stack serverless app, you are ready to deploy it to production.
Deploy to Prod
We are now going to deploy our app to prod. You can go ahead and stop the local development environments for SST and React.
Run the following in your project root.
$ npx sst deploy --stage production
This command will take a few minutes as it’ll deploy your app to a completely new environment. Recall that we are deploying to a separate prod environment because we don’t want to affect our users while we are actively developing our app. This ensures that we have a separate local dev environment and a separate prod environment.
At the end of the deploy process you should see something like this.
+ Complete
Api: https://7qdwu0iuga.execute-api.us-east-1.amazonaws.com
Frontend: https://d1wyq16hczgtjw.cloudfront.net
...
Set Secrets in Prod
We also need to configure out secrets for production. You’ll recall we had previously configured secrets for our local stage.
We’ll do the same here but for production
.
Run the following in your project root.
$ npx sst secret set --stage production StripeSecretKey <YOUR_STRIPE_SECRET_TEST_KEY>
You can run npx sst secret list --stage production
to see the secrets for prod.
Our full-stack serverless app is almost ready to go. You can play around with the prod version.
Custom Domains
However the API is currently on an endpoint that’s auto-generated by API Gateway.
https://5bv7x0iuga.execute-api.us-east-1.amazonaws.com
And the frontend React app is hosted on an auto-generated CloudFront domain.
https://d3j4c16hczgtjw.cloudfront.net
We want to host these on our own domain. Let’s look at that next.
For help and discussion
Comments on this chapter