Closed howardya closed 7 years ago
You would have to integrate with Cognito Identity to obtain AWS credentials. Basically use case 17. Follow the docs to do that and after obtaining credentials, you can use the AWS SDK to make calls to Dynamo:
I do not have AWS as a global variable and do not wish to. I only want to import the relevant services. So I am not sure how to apply Use Case 17 to my case.
What I am looking for is a way to
const dynamodb = new DynamoDB({
credentials: ???
});
After referring to this I have modified it to be the following
let Logins = {};
Logins[`cognito-idp.${appConfig.region}.amazonaws.com/${appConfig.UserPoolId}`] = 'xxx';
const myCredentials = new CognitoIdentityCredentials({
IdentityPoolId: appConfig.IdentityPoolId,
region: appConfig.region,
Logins: Logins
});
const dynamodb = new DynamoDB({
IdentityPoolId: appConfig.IdentityPoolId,
region: appConfig.region,
credentials: myCredentials
});
I still have Error: Missing credentials in config
This SDK won't give you the ability to access DynamoDB. You should use the main AWS JavaScript SDK for that. You can build a slimmed down version of the AWS SDK that only accesses DynamoDB following instructions on their page.
You would also need to make a call to refresh or get to actually retrieve the credentials.
Hi, can I ask, how can I integrate this package with the DynamoDB? I only want authenticated users to have access to my dynamo database. Greatly appreciate any advice or help with this.