Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

236
Views
Comma separator in Lambda function environment settings using the Serverless Framework

I am trying to add a MongoDB cluster as part of a Serverless deployment, but I can't set the environment variable.

Here is part of the serverless.yml file:

service: serverless-test

plugins:
  - serverless-offline

provider:
  name: aws
  runtime: nodejs4.3
  environment:
    MONGO_URI: "mongodb://mongo-6:27000,mongo-7:27000,mongo-8:27000/db-dev?replicaSet=mongo"

How do I pass the MONGO_URI to contain the cluster as a comma separated value?

Any advise is much appreciated.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Unfortunately, you can't use commas in Lambda environment variables. This is an AWS limitation and not a Serverless issue.

For example, browse the AWS console and try to add a environment variable that contains a comma:

environment variable foo,bar

When you save, you will get the following error:

1 validation error detected: Value at 'environment.variables' failed to satisfy constraint: Map value must satisfy constraint: [Member must satisfy regular expression pattern: [^,]*]

The error message says that the regex [^,]* must be satisfied and what this small regex explicitly says is to not (^) accept the comma (,). Any other char is acceptable.

I don't know why they don't accept the comma and this is not explained in their documentation, but at least their error message shows that it is intentional.

As a workaround, you can replace your commas by another symbol (like #) to create the env var and replace it back to comma after reading the variable, or you will need to create multiple env vars to store the endpoints.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!