Search code examples
pythonaws-lambdaserverless

how to pass param to service in serverless.yaml


I'm try to set environment in serverless.yaml

service: ${param:env, 'dev'}-backend-offline-onboard
frameworkVersion: '2 || 3'

I'm using command

sls deploy --param="env=dev" -c serverless.yml

but error

Cannot resolve serverless.yml: "service" property is not accessible (configured behind variables which cannot be resolved at this stage)

how to pass param to service in serverless


Solution

  • You can use any custom param in serverless. In the command you just have to pass it as

    serverless deploy --customParam testTest
    

    in the serverless.yml file you can use your passed params anywhere as ${opt:customParam}