1
votes

I have lambda Function which is present in between SNS and SQS

Lambda(contains logic to filter out or limit messages from SNS and pushes messages to SQS).

we have different Queue url for stage,prod and test

is there any possible way, so that i can have environment variables in aws-lambda to access different queues in different environments.

I have been thinking about downloading environment related configuration file from S3 inside Lambda and correspondingly access SQS.

and also checked aws env doc : http://docs.aws.amazon.com/lambda/latest/dg/env_variables.html

1

1 Answers

3
votes

It depends on how you are deploying your Lambda, SNS and SQS resources. If you are using CloudFormation you can export the names, then import them into your Lambda as environment variables.

Inside your lambda you would use something like for Javasript:

process.env.SQS_QUEUE_NAME

In Java you would use:

System.getenv("NAME_OF_YOUR_ENV_VARIABLE");

You can also go to the Lambda console and add environment variables manually.