Complete the code to define a Lambda function resource in SAM.
Resources:\n MyFunction:\n Type: AWS::Serverless::Function\n Properties:\n Handler: index.handler\n Runtime: nodejs14.x\n CodeUri: [1]The CodeUri property specifies the location of your Lambda function code. It should point to the folder or S3 location containing your code, such as ./src/.
Complete the code to specify the API event trigger for the Lambda function.
Resources:\n MyFunction:\n Type: AWS::Serverless::Function\n Properties:\n Events:\n ApiEvent:\n Type: Api\n Properties:\n Path: /hello\n Method: [1]The Method property defines the HTTP method that triggers the Lambda function. Common methods include GET and POST. Here, GET is used.
Fix the error in the SAM template to correctly define the function's memory size.
Resources:\n MyFunction:\n Type: AWS::Serverless::Function\n Properties:\n MemorySize: [1]The MemorySize property expects an integer value representing the amount of memory in MB. So, 512 is correct, not strings with units.
Fill both blanks to define environment variables for the Lambda function.
Resources:\n MyFunction:\n Type: AWS::Serverless::Function\n Properties:\n Environment:\n Variables:\n STAGE: [1]\n LOG_LEVEL: [2]
Environment variable values must be strings, so they need quotes. STAGE is set to "prod" and LOG_LEVEL to "INFO".
Fill all three blanks to define a simple SAM template with a function, API event, and timeout.
Resources:\n HelloWorldFunction:\n Type: AWS::Serverless::Function\n Properties:\n Handler: app.lambda_handler\n Runtime: python3.9\n Timeout: [1]\n Events:\n HelloApi:\n Type: Api\n Properties:\n Path: /hello\n Method: [2]\n CodeUri: [3]
The Timeout is set as an integer (seconds), here 10. The API method is GET. The CodeUri points to the folder ./hello_world/ where the code is located.