AWS Lambda Hands-On| Part-2

docker cp peaceful_allen:/adityaLearningLambda .
sudo apt-get update && apt-get install maven
sam build
root@9090f8d966d0:/adityaLearningLambda# cat template.yamlAWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
adityaLearningLambda

Sample SAM Template for adityaLearningLambda

# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 20

Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: HelloWorldFunction
Handler: helloworld.App::hello
Runtime: java8
MemorySize: 512
package helloworld;

public class App {
public String hello() {
return "First Awesome hello from Lambda Functions..";
}
}
sam build
sam deploy
package helloworld;

public class App {
public String hello(String firstParameter) {
return "Executed lambda function along with paramtere in request.." + firstParameter;
}
}
sam build
sam build
sam deploy
sam logs -n HelloWorldFunction --stack-name adityaLambdaFirstStack --tail
java.lang.RuntimeException: An error occurred during JSON parsingCaused by: java.io.UncheckedIOException: com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.String out of START_OBJECT token
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
adityaLearningLambda

Sample SAM Template for adityaLearningLambda

# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: HelloWorldFunction
Handler: helloworld.App::hello
Runtime: java8
MemorySize: 512
Globals:
Function:
Timeout: 20
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "*"
}
]
}
aws cloudformation delete-stack --stack-name adityaLambdaFirstStack

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store