Goalist Blog
Published in

Goalist Blog

Connect an application using serverless framework to an existing DynamoDB

Few things we need to know before we start:

  • Serverless framework is a framework that helps develop, deploy, troubleshoot and secure your serverless applications and provide you with full serverless application lifecycle management. It works with many different cloud provider like AWS, Azure, Alibaba Cloud, … and very easy to install with multiple options for you to start with.
    https://www.serverless.com/framework/docs/providers/aws/guide/installation
  • DynamboDB is a NoSQL Database and is on of the Amazon Web Services.

Now, I assumed that you have your serveless app ready and connected to AWS provider. So, let’s get to the main part.

The file that manage connection between your serverless app and the database is serverless.yml . When you install the serverless framework, it probably have yml file ready to help you create table once you run your application.

If you want to connect your app to existing DB that you’ve created, first thing to do is comment out or remove below part:

Basic info to create table, just the same as when you create directly from DynamoDB Page

Then, adjust the provider part as below. The Resource: part is like a place where you define the address of your database. There’re serveral way to define this, either you put it in .env to make it secured or just put directly as below screenshot, becasue even if people see that address below, they still need your account to be able to access the db.

To find this arn, go to your table details in DynamoDB and copy the Amazon Resource Name (ARN) . And voila, now try to test your api to add or edit the item in your table.

Although it seems extremely easy, if you’ve just started with Amazon services like i do, it’d take tons of time. So, i hope this helps.

I’m Linh from Goalist. See you in another story 😊

--

--

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