1 year ago

#73775

test-img

Yatin Pandit

How to add the service name using env vairables in serverless.yml

I am trying to set the serverless service name from the env file.

I have written it as

service: ${env:SERVICE_NAME}

It worked perfectly in previous versions of serverless framework. However since I upgraded it to the latest version, it has started throwing error stating

  The stack service name "${env:SERVICE_NAME}-dev" is not valid. A service name should only contain alphanumeric (case sensitive) and hyphens. It should start with an alphabetic character and shouldn't exceed 128 characters.

I have tried setting the service name manually and it works like charm. But the with env variable it stops working.

I have added all the plugins properly and the env variables works on different sections like resources and provider. It just not work in service name.

#serverless.yml

service: ${env:SERVICE_NAME}

plugins:
  - serverless-plugin-warmup
  - serverless-python-requirements
  - serverless-wsgi
  - serverless-dotenv-plugin
  - serverless-attach-managed-policy
  - serverless-api-gateway-caching

python-3.x

amazon-web-services

boto3

serverless

serverless-framework

0 Answers

Your Answer

Accepted video resources