narrow-leather-14091
08/03/2023, 7:53 AMlittle-cartoon-10569
08/03/2023, 8:36 PMnarrow-leather-14091
08/04/2023, 7:50 AMjolly-megabyte-6233
08/04/2023, 8:21 AMnarrow-leather-14091
08/04/2023, 10:30 AMjolly-megabyte-6233
08/04/2023, 12:50 PMnarrow-leather-14091
08/04/2023, 2:35 PMjolly-megabyte-6233
08/06/2023, 6:29 AMis it possible to have a connection to DynamoDB from a local machine?@narrow-leather-14091 yes it's totally possible. the local machine needs to configure credentials for an AWS user/role that has access to the resource (any AWS resource, not only DynamoDB). all access is ultimately governed by IAM policies and as long as the user/role has (at least) the same permissions as your lambda, you can just run the lambda code locally (you'll need to define the table name, region, etc. one way to do this is via environment variables). (It can be more complicated if the resources are in a VPC.)
narrow-leather-14091
08/08/2023, 6:20 AMjolly-megabyte-6233
08/08/2023, 10:02 AMnarrow-leather-14091
08/08/2023, 10:43 AMjolly-megabyte-6233
08/08/2023, 1:40 PM"Error read item from DynamoDB ResourceNotFoundException: Requested resource not found"Here's what i'd do to figure this out: 1. First: Validate that the table actually exsists. log into to the AWS console and go to the dynamo tables and check a. that the table actually exists b. that is actually has the name you think it has c. and that it exists in the correct region 2. Then: Make a minimal working example for a simple PUT request to the table. (The goal is to valiate if your local setup is actually able to interact with your specific table.) a. create a small
tmp-script.js
file that you run via node/ts-node
const AWS = require('aws-sdk');
const REGION = 'YOUR_AWS_REGION';
const TABLE = 'YOUR_TABLE_NAME';
const dynamoDb = new AWS.DynamoDB.DocumentClient({ region: REGION });
const script = async () => {
try {
const response = await dynamoDb.put({
TableName: TABLE,
Item: {
// ... your item (needs to have the correct primary key)
}
}).promise();
console.log(JSON.stringify(response));
} catch (error) {
console.error('Error putting item into DynamoDB', error);
}
};
script();
Now: This should work. If it does not, it might be that your AWS user is not allowed to access the table.
Afterwards, update the code in the handler and make the handler work by running it locally.
Afterwards, deploy.ARN formatNah. The
TableName
parameter should be the table name - I think DynamoDB tables are uniquely identified via the triple [account, region, name].narrow-leather-14091
08/08/2023, 2:25 PM