Complete the code to specify the runtime environment for the Lambda function.
lambda_function = aws.lambda_.Function("MyFunction", runtime=aws.lambda_.Runtime.[1], handler="index.handler", code=aws.lambda_.Code.from_asset("./app") )
The runtime specifies the language environment for the Lambda function. Here, NODEJS_14_X is a valid and common runtime.
Complete the code to set the Lambda function's handler correctly.
lambda_function = aws.lambda_.Function("MyFunction", runtime=aws.lambda_.Runtime.NODEJS_14_X, handler="[1]", code=aws.lambda_.Code.from_asset("./app") )
The handler is the entry point for the Lambda function. It usually follows the format 'file.method'. Here, 'index.handler' means the handler function inside index.js.
Fix the error in the code by choosing the correct method to load the Lambda function code from a local folder.
lambda_function = aws.lambda_.Function("MyFunction", runtime=aws.lambda_.Runtime.NODEJS_14_X, handler="index.handler", code=aws.lambda_.Code.[1]("./app") )
The correct method to load code from a local folder is 'from_asset'. Other options are invalid and cause errors.
Fill both blanks to add environment variables to the Lambda function.
lambda_function = aws.lambda_.Function("MyFunction", runtime=aws.lambda_.Runtime.NODEJS_14_X, handler="index.handler", code=aws.lambda_.Code.from_asset("./app"), environment={ [1], [2] } )
The environment property expects a dictionary of key-value pairs. Here, "ENV": "dev" and "DEBUG": "true" are valid key-value pairs.
Fill all three blanks to create a Lambda function with a timeout, memory size, and description.
lambda_function = aws.lambda_.Function("MyFunction", runtime=aws.lambda_.Runtime.NODEJS_14_X, handler="index.handler", code=aws.lambda_.Code.from_asset("./app"), timeout=[1], memory_size=[2], description=[3] )
The timeout should be set using Duration.minutes(5) for 5 minutes. Memory size is an integer like 128 MB. Description is a string describing the function.