Search code examples
aws-lambdaaws-amplifyaws-amplify-cli

Should I create database update function outside of amplify?


I have an app that gets data from dynamodb with a lambda function. And I want to update the database periodically with another lambda function that makes a request to an external api to get data.

I created all functions with amplify-cli but I think it wasn't a good idea. And with this way I also stuck on making external request authentication because I can't upload client secret json file with the function.

Should I create the updater function outside of amplify-cli? If so, how should I do it?

Thanks


Solution

  • Amplify is most useful when creating external resources that a front-end application will call over the public Internet.

    If you need to periodically execute some logic, you probably don't need to make it publicly available. I suggest to create a scheduled execution Lambda function, using a CloudWatch event as a periodic trigger.

    Here's an example of how to do that.

    The Lambda function you write can call DynamoDB directly to query/update values.