package example;
import java.io.*;
import com.amazonaws.services.lambda.runtime.Context;
public class LambdaMethodHandler {
public String handlerString(String input,Context context) {
System.out.println(input.length());
return input;
}
}
// This is my function policy
{
"Version": "2012-10-17",
"Id": "default",
"Statement": [
{
"Sid": "sns-xxxx-Sns_Lambda_test",
"Effect": "Allow",
"Principal": {
"Service": "sns.amazonaws.com"
},
"Action": "lambda:invokeFunction",
"Resource": "arn:aws:lambda:xxxxx:function:theSimplestLambda",
"Condition": {
"ArnLike": {
"AWS:SourceArn": "arn:aws:sns:eu-west-1:xxxx:Sns_Lambda_test"
}
}
}
]
}
答案 0 :(得分:0)
显然,aws lambda被正确调用了,之所以我在处理程序中显示的字符串的长度因为我在lambda内部的参数而没有显示,为了处理某些内容来自SNS的输入我必须在参数中接受SNSevent类型的事件,然后再处理它。