Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

238
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda