I am creating a function which is supposed to write to a dynamodb and I want to generate the trace using aws-xray-sdk.
My function is
private readonly docClient: DocumentClient = AWS.DynamoDB.DocumentClient()
async createTodo(todoItem: TodoItem): Promise<TodoItem> {
await this.docClient.put({
TableName: this.todosTable,
Item: todoItem
}).promise()
return todoItem
}
This works very well when I use just the document client from aws sdk as above but because I need the trace when I pass the aws-sdk through the aws-xray-sdk and wants to use the sdk it throws an error. This is how I constuct it.
import * as AWS from 'aws-sdk'
import * as AWSXRay from 'aws-xray-sdk'
const XAWS = AWSXRay.captureAWS(AWS)
then when I do
private readonly docClient: DocumentClient = XAWS.DynamoDB.DocumentClient()
I get the error
TS2339: Property 'DocumentClient' does not exist on type
'PatchedAWSClientConstructor<ClientConfiguration, typeof DynamoDB>'.
How can I do to eliminate this error or possibly get a document client that can be used for the trace with aws-xray.
Dependencies. "aws-xray-sdk": "^2.2.0", "aws-sdk": "^2.433.0",
Using const AWSXRay = require('aws-xray-sdk') worked for me
Please use
import AWSXRay from "aws-xray-sdk-core";
This was explained on a similar issue on the AWS X-Ray JS SDK repo: https://github.com/aws/aws-xray-sdk-node/issues/491
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With