0

im moving report generation to aws lambda to remove this load from main application, but i also need to manage different execution environments, dev, stage and production. for this purpose i manage a set of environment variables where are defined urls for Mysql, Redis, AWS S3 credentials, bucket and so depending of my needs.

i can configure these environment variables from lambda console, but to achieve a set of testing environments i would need to have 3 configured functions, one for dev, another for stage and one more for production.

what i want to achieve is that my project can read from configured environment variables and set the values on startup, this way i don't need to worry about maintaining it from the aws console. my codebase is on java using spring, im guessing there is some java API to manage aws lambda.

i've been searching for this but no luck so far, also im open for suggestions.

1 Answer 1

2

You need to use the updateFunctionConfiguration function from aws-sdk to update your lambda configuration dynamically.

However, a better way of doing this is using lambda versioning and aliases. For the same function, you can create a version for each of the environments you have and then create an alias for it. Each version can have its own set of environment variables independent of other versions. When you invoke your function, you'll have to pass a parameter called qualifier with the value as you environment alias/version name. This can be done through setQualifier before you invoke.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.