Issue with Setting MONGO=$(MONGO_DB_SVC) in LocalStack Lambda Environment Variables

Greetings LocalStack Community,

I’ve recently deployed LocalStack using Helm and encountered an issue while trying to set the MONGO environment variable for my Lambda functions. My objective is to obtain the IP address associated with $MONGO-DB-SVC and pass it as an environment variable to the Lambda functions.

Here’s a snippet of my current LocalStack configuration:

localstack:
  debug: true
  serviceAccount:
    create: true
  node-role:
    name: "localstack"
  mountDind:
    enabled: true
    forceTLS: false
  extraEnvVars:
    - name: LAMBDA_DOCKER_FLAGS
      value: -e MONGO=$(MONGO_DB_SVC)

However, upon executing a Lambda function to retrieve all environment variables, the value of MONGO=$(MONGO_DB_SVC) doesn’t reflect the actual IP address as intended.

The resulting environment variables retrieved from the Lambda function are as follows:

{
  "statusCode": 200,
  "body": {
    "AWS_LAMBDA_FUNCTION_VERSION": "$LATEST",
    // ... (other environment variables)
    "MONGO": "$(MONGO_DB_SVC)"
  }
}

As observed, the value of MONGO remains as $(MONGO_DB_SVC) instead of presenting the actual IP address.

I’m seeking guidance on how to appropriately pass the IP address associated with $MONGO-DB-SVC as an environment variable to my Lambda functions within the LocalStack environment. Any suggestions or insights into resolving this issue would be greatly appreciated.

Thank you for your time and support.

Hi @cflmarques,

Please refer to Ways to set environment variables with Compose | Docker Docs.

If needed, please have a look at
Network troubleshooting | Docs (localstack.cloud)
DocumentDB (DocDB) | Docs (localstack.cloud)

Thank you.
I implemented an alternative solution by running an EKS job to provision all secrets, including the $MONGO-DB-SVC.