Is there a way to add Lambda function without API to AWS Mobile Hub project?

253 Views Asked by At

One can add Lambda function that implements API through Cloud Logic to project like this.

cloudlogic: !com.amazonaws.mobilehub.v0.CloudLogic components: hello: !com.amazonaws.mobilehub.v0.API attributes: name: hello requires-signin: true paths: /hello: !com.amazonaws.mobilehub.v0.Function name: hello codeFilename: uploads/hello-xxx.zip handler: lambda.handler enableCORS: true runtime: nodejs6.10 environment: {}

But what about functions that has other triggers like updates in database, regular interval, etc. How these kind of functions can be added so that they integrated part of project? What is the syntax? Sure I can deploy functions separately, but I would be nice to deploy everything from same project file.

3

There are 3 best solutions below

0
On

Lambda functions are not made for implementing API through Cloud Logic or similar specific things. Lambda functions can be used in many ways.

AWS Lambda is a compute service that lets you run code without provisioning or managing servers.

For triggers like doing some task on regular interval you can define crons. Read more about them here.

People can help you better if you explain what you want to achieve.

2
On

AWS Lambda functions can be invoked by a number of different types of events, for example, an API call or an object being put in S3. AWS Mobile Hub only creates lambda functions to back APIs in the Cloud Logic feature, however, you can add any number of lambda functions triggering off events on any resources in your account.

This project demonstrates adding an S3 notification trigger which invokes an AWS Lambda function to transcode video files that were uploaded to the mobile hub project's "userfiles" S3 bucket, for example.

https://github.com/aws-samples/aws-mobile-simple-video-transcoding
(related AWS re:Invent session... https://www.youtube.com/watch?v=_-mZPwmR94I&t=785s)

Such notification triggers can be added via the AWS CLI or from AWS service consoles.

0
On

Here is the syntax of project file and it seems that currently only Lambda functions serving APIs can be deployed within a mobile hub projects.