Is there a difference when using Handler function to invoke AWS Lambda, and when using Invoke(input *InvokeInput) function in Go?
I need my Lambda to be invoked in multiple ways. For example, sometimes I need it to be invoked synchronously (as REST API) and sometimes I need it to be invoked asynchronously. How do I achieve this?
Do I create something like this:
func main(){
svc := lambda.New(session.New())
input := &lambda.InvokeInput{
ClientContext: aws.String("MyApp"),
FunctionName: aws.String("MyFunction"),
InvocationType: aws.String("Event"),
LogType: aws.String("Tail"),
Payload: []byte("fileb://file-path/input.json"),
Qualifier: aws.String("1"),
}
result, err := svc.Invoke(input)
if err != nil {
....
}
}
Or do I create a Handler function like this:
func main(){
lambda.Start(Handler)
}
func Handler(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error){
....
}
How do I handle both cases where sometimes I need to invoke lambda asynchronously and provide input payload as JSON, and sometimes I need to invoke lambda synchronously (REST API) and provide input as HTTP Request? Is there a way to Invoke lambda as a REST API without passing events.APIGatewayProxyRequest
as an function argument?