9

I implement AWS Lambda function on Java using AWS Java SDK and AWS Lambda Java Support Libraries and in some cases I need to get name, version and alias of current function right in code of the function.

Name and version I can get from Context using getFunctionName() and getFunctionVersion() methods. But how can I get current alias value?

1

1 Answer 1

10

You can use the Context object passed into the lambda handler to get that data. https://docs.aws.amazon.com/lambda/latest/dg/java-context-object.html

The context object properties are:

getMemoryLimitInMB(): Memory limit, in MB, you configured for the Lambda function.

getFunctionName(): Name of the Lambda function that is running.

getFunctionVersion(): The Lambda function version that is executing. If an alias is used to invoke the function, then getFunctionVersion will be the version the alias points to.

getInvokedFunctionArn(): The ARN used to invoke this function. It can be function ARN or alias ARN. An unqualified ARN executes the $LATEST version and aliases execute the function version it is pointing to.

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.