简体   繁体   English

在代码中获取AWS Lambda函数的别名

[英]Get alias name of AWS Lambda function in code

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. 我使用AWS Java SDKAWS Lambda Java支持库在Java上实现AWS Lambda函数,在某些情况下,我需要在函数代码中获取当前函数的名称,版本和别名。

Name and version I can get from Context using getFunctionName() and getFunctionVersion() methods. 我可以使用getFunctionName()和getFunctionVersion()方法从Context获取名称和版本。 But how can I get current alias value? 但是如何获得当前的别名值呢?

You can use the Context object passed into the lambda handler to get that data. 您可以使用传递给lambda处理程序的Context对象来获取该数据。 https://docs.aws.amazon.com/lambda/latest/dg/java-context-object.html 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. getMemoryLimitInMB():为Lambda函数配置的内存限制(MB)。

getFunctionName(): Name of the Lambda function that is running. getFunctionName():正在运行的Lambda函数的名称。

getFunctionVersion(): The Lambda function version that is executing. getFunctionVersion():正在执行的Lambda函数版本。 If an alias is used to invoke the function, then getFunctionVersion will be the version the alias points to. 如果使用别名来调用该函数,则getFunctionVersion将是别名指向的版本。

getInvokedFunctionArn(): The ARN used to invoke this function. getInvokedFunctionArn():用于调用此函数的ARN。 It can be function ARN or alias ARN. 它可以是功能ARN或别名ARN。 An unqualified ARN executes the $LATEST version and aliases execute the function version it is pointing to. 不合格的ARN执行$ LATEST版本,别名执行它指向的函数版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM