官术网_书友最值得收藏!

Function code

Here, you are required to write the code. The Lambda function has a predefined pattern for writing the code. While writing the code, you need to understand the context. Lambda provides three kinds of feasibility, which decides your runtime execution for the code:

  • Code entry type: This section provides three options to decide the entry type for your code, such as editing code inline, uploading a ZIP file, and uploading a file from Amazon S3.
  • Runtime: This section provides options to decide the runtime programming language context for your code, such as Python, C#, NodeJS, and Java.
  • Handler: A handler defines the path to your method/function, such as <filename>.<method_name>. For example, if you want to execute a function named as a handler, which is defined in main.py, then it would be main.handler.

Let's get back to our newly created hello world function named lambda_handler.

Here, the handler value is defined as lambda_function.lambda_handler, where lambda_function.py is the filename and lambda_handler is the method name:

def lambda_handler(event, context): 
    print("value1 = " + event['key1']) 
    print("value2 = " + event['key2']) 

Lambda_handler accepts two positional arguments, event and context:

  • event: This argument contains event-related information. For example, if we configure the Lambda function with Amazon S3 bucket events, then we would get S3 bucket information in event arguments, such as bucket name, region, and so on.
  • context: This argument contains the context-related information that may be required during runtime for code execution.
主站蜘蛛池模板: 晋中市| 潞城市| 思南县| 南阳市| 邵阳市| 左贡县| 涿州市| 广饶县| 乐昌市| 津南区| 东乡县| 比如县| 临桂县| 平顶山市| 万宁市| 长沙县| 清流县| 太保市| 通道| 鹤庆县| 元朗区| 紫云| 中牟县| 安顺市| 栖霞市| 乾安县| 长子县| 大城县| 凉山| 汉源县| 阳山县| 红安县| 宜春市| 鄂温| 扎囊县| 晋城| 双牌县| 陆河县| 乾安县| 贵定县| 达日县|