Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS Dynamo DB - Insert #17

Open
akpuvvada opened this issue Dec 13, 2019 · 4 comments
Open

AWS Dynamo DB - Insert #17

akpuvvada opened this issue Dec 13, 2019 · 4 comments

Comments

@akpuvvada
Copy link

We installed 'DynamoDB Insert' component and using the activity to insert a record.
Below is the mapping for Record Data.

I see two issues:

  1. While building the FLogo app seeing below notification:
Generating metadata for legacy actvity: github.com/retgits/flogo-components/activity/dynamodbinsert
Installed legacy activity: github.com/retgits/flogo-components/activity/dynamodbinsert
Installed Legacy Support
  1. When executing the Lambda function in AWS, getting bellow error:
2019-12-13T19:40:25.404Z	ERROR	[flogo.activity.dynamodbinsert] -	Execution failed for Activity[dynamodbinsert_14] in Flow[Lambda_GET_WeatherLimit_POC] - interface conversion: interface 
{}
 is []interface 
{}
, not string

Please help!

Record Mapping:

"DynamoDBRecord": {
                  "mapping": [
							  {
								"Name": "RecordID",
								"Value": "=number.random(1000000)"
							  },
							  {
								"Name": "ZCode",
								"Value": "=$flow.CityCode_Input.Records[0].dynamodb.NewImage.zcode.S"
							  },
							  {
								"Name": "lastTemp",
								"Value": "=$activity[rest_3].data[0].Tl.Value"
							  },
							  {
								"Name": "lastUpdated",
								"Value": ""
							  }
							]
                }
@akpuvvada
Copy link
Author

Someone, please help.

@akpuvvada
Copy link
Author

Getting similar error in Query activity as well:

2019-12-16T18:59:25.509Z	ERROR	[flogo.activity.dynamodbquery] -	Execution failed for Activity[dynamodbquery_15] in Flow[Lambda_GET_WeatherLimit_POC] - interface conversion: interface 
{}
 is nil, not string

Code for your reference:

{
            "id": "dynamodbquery_15",
            "name": "DynamoDB Query",
            "description": "Query objects from Amazon DynamoDB",
            "activity": {
              "ref": "#dynamodbquery",
              "input": {
                "awsAccessKeyID": "*******",
                "awsSecretAccessKey": "********",
                "awsRegion": "us-east-2",
                "dynamoDBTableName": "test_Lambda",
                "dynamoDBKeyConditionExpression": "=string.concat(\"ZipCode = \", $flow.CityCode_Input.Records[0].dynamodb.NewImage.zipcode.S)"
              }
            }
          }

@akpuvvada
Copy link
Author

Please help!

@retgits
Copy link
Owner

retgits commented Dec 23, 2019

Hi 👋 !

To answer your questions:

  1. The notification you mentioned isn't an issue. The activities in this repository were built with the previous contribution model for Project Flogo and that is backward compatible with the newer model due to the legacy support bridge the team has built.

  2. It looks like you're passing in a named JSON array as the input to DynamoDBRecord. The record cannot be a named JSON array so it should be something like [ { "Name": "RecordID", "Value": "x" }, { "Name": "ZCode", "Value": "x" }, { "Name": "lastTemp", "Value": "x" }, { "Name": "lastUpdated", "Value": "x" } ]

  3. For the query, the key condition expression use placeholders (such as :name and :sub) instead of actual values. In relies on the dynamoDBExpressionAttributes to provide the actual values. Looking at the code from your insert question, you could have something like:

{
"dynamoDBKeyConditionExpression": "RecordID = :item",
"dynamoDBExpressionAttributes": "[{\"Name\":\":item\",\"Value\":\"x\"}]"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants