Serverless - Multiple Services - local testing

I’m wondering how I can force my local serverless deployment to mimic what happens when I deploy it to AWS.

Here is my serverless yaml file:

service: payment # NOTE: update this with your service name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
# frameworkVersion: "=X.X.X"
environment:
SLS_DEBUG: "*"

provider:
name: aws
runtime: nodejs8.10
stage: production
region: ca-central-1
timeout: 60
role: ${file(../config/prod.env.json):ROLE}
vpc:
    securityGroupIds:
    - ${file(../config/prod.env.json):SECURITY_GROUP}
    subnetIds:
    - ${file(../config/prod.env.json):SUBNET}
apiGateway:
    apiKeySourceType: HEADER
apiKeys:
    - ${file(../config/prod.env.json):APIKEY}

package:
include:
    - ../lib/**

functions:
- '${file(src/handlers/payment.serverless.yml)}'

plugins:
- serverless-offline

My file structure looks like this:

root
--- node_modules
--- lib
    - models
--- payment
    - serverless.yml

When I deploy it to AWS the lib folder gets put into the lambda function’s folder but locally I need to define its path which usually is …/…/…/

How can I make it so that locally or deployed I don’t have to change the paths?

1 Like