vishwamannam623297

How to connect to Amazon DynamoDB using AWS API Gateway

Discussion created by vishwamannam623297 on May 8, 2018

Please download the attached .PDF of the following information for instructions with images to clarify each step. 

 

Here's the overview of what's in the .PDF:

Inserting new rows or overriding existing rows to the table using API

Creating the Policy

Creating the Role

Creating the API

Connecting to DynamoDB from Boomi

Get the items

Create or Update the Item

 

Insert new rows or overriding existing rows to the table using API

See image of simple DynamoDB table created in AWS

 

Creating the Policy

To create the API, we need to create a policy that may require the table resource path if you want to allow access to only particular table or you can choose option to allow access to all tables.

 

 After creating the policy create a role (allows API gateway) and add the created policy to the role.

 

Creating the Role

  

Copy the Role ARN, which will be used while creating the API.

 

Creating the API

 

After creating the API, create the Resource and then method.

 

Then create a method, here selecting the POST, as I want to insert or edit the table rows.

To the execution role box, paste the role ARN that copied before.

 

Edit the integration request, to frame the API request that accept the input request parameters

 

Request that accepts request parameters myId, notes, date

 

{

    "TableName": "TestS",

    "Item": {

              "myId": {

            "S": "$input.path('$.myId')"

            },

        "notes": {

            "S": "$input.path('$.notes')"

            },

        "date": {

            "S": "$input.path('$.date')"

        }

    }

}

 

 

We can test the API clicking on TEST.

 

Request used to POST the data.

{

  "myId":   "103",

  "notes": "Checking the API",

  "date":  "May 06,2018"

}

 

Now the table is updated with new values.

 

 

To get the table row details on primary key we can create the GetItem resource.

Let’s see how to fetch the details by passing the path parameter myid.

.

Create one more resource under myid resource

 

 

Then create the GET method.

 

 

Input the Action as Query.

 

Edit the integration request, to frame the API request that accept the input request parameters

Click on body mapping template to form the request.

 

{

    "TableName": "TestS",

    "PrimaryKey": "myId",

    "KeyConditionExpression": "myId = :v1",

    "ExpressionAttributeValues": {

        ":v1": {

            "S": "$input.params('myId')"

        }

    }

}

 

 

Test the API by leveraging the TEST button.

Attachments

Outcomes