Skip to content

Create a new serverless App & Service

Source: Notion | Last edited: 2024-11-16 | ID: 8df74ecd-6ef...


Use serverless command to create new app

image

image

Create a service in the Serverless dashboard

Section titled “Create a service in the Serverless dashboard”

Here are the steps:

  1. Add org and app in the serverless.yml file; See the example below

image

  1. Run deployment command: sls deploy --stage dev, by default Serverless will deploy the service to the org level default provider AWS dev account (eonlabs-dev)
  2. In the newly created service, overwrite the default provider to eonlabs-dev (avoid inheriting from org provider since it can cause problems down the road when/if someone accidentally change org level provider)

image

image

  1. Under the same service, create a new prod stage through UI, manually change the stage level provider to be eonlabs-prod

image

image

image

  1. Double-check to make sure:
  2. The dev stage points to the eonlabs-dev provider (inherited from the service level provider)
  3. The prod stage points to the eonlabs-prod provider (overrides provider from the service level provider)
  4. Run serverless deploy --stage prod, ensure the eonlabs-prod provider is used in the deployment, as highlighted in the image below.

image

How provider inheritance works in the Serverless framework:

Section titled “How provider inheritance works in the Serverless framework:”

The provider feature has multiple levels of inheritance that you can override.

  1. If you set a default provider in the org menu, then all deployed services and stages inherit that provider by default

  2. You can go to the settings for a service as a whole by clicking the menu on the far right of the service name in the apps view, switching to “provider” and choosing a different provider. All stages within that service will use that provider by default

  3. Within a specific stage, you can switch to the “provider” tab and then choose a provider exclusively for that stage, overriding the defaults from org and service settings.

Read more

Configure Github Action Environment Secrets

image