# Aws-sdk dynamo db doesn't execute query in rules

**URL:** <https://community.auth0.com/t/aws-sdk-dynamo-db-doesnt-execute-query-in-rules/68416>\
**Category:** Get Help\
**Tags:** bug\
**Created:** [August 23, 2021, 4:53pm UTC](https://community.auth0.com/t/aws-sdk-dynamo-db-doesnt-execute-query-in-rules/68416 "2021-08-23T16:53:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![steven.varga](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/steven.varga/32/31288_2.png) [@steven.varga](https://community.auth0.com/u/steven.varga)\
**Post date:** [August 23, 2021, 4:53pm UTC](https://community.auth0.com/t/aws-sdk-dynamo-db-doesnt-execute-query-in-rules/68416/1 "2021-08-23T16:53:14Z")

</div>

I am having difficulty to execute an aws-sdk dynamodb api call within auth0 RULEs, which otherwise worked in ACTIONs and HOOKs. Since ACTIONs do not fire pre-registration, and HOOKs don’t work work for social logins, the last resort is to use RULEs.

Does anyone have experience with executing `aws-sdk` dynamoDB queries from Auth0 rules? Can someone point out what am I doing wrong in the following snippet?

```auto
function(user, context, callback) {
  const AWS = require('aws-sdk@2.458.0');

var db = new AWS.DynamoDB({
    accessKeyId: configuration.AWS_KEY_ID, 
    secretAccessKey: configuration.AWS_SECRET, 
    region: configuration.AWS_REGION
});

const run = async () => {
    try {
      console.log("before call await list tables...");
      const results = await db.listTables({}).promise();
      console.log("we should have a result here...");
      console.log(results.TableNames.join("\n"));
    } catch (err) {
      console.log("or some sort of error thrown:", err);
    }
  };
  run();
  return callback(null, user, context);
}

```

best wishes: steve

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [August 24, 2021, 8:26pm UTC](https://community.auth0.com/t/aws-sdk-dynamo-db-doesnt-execute-query-in-rules/68416/3 "2021-08-24T20:26:29Z")

</div>

Working through this issue here:

> [@Auth0 post registration action doesn't work](https://community.auth0.com/t/auth0-post-registration-action-doesnt-work/68355/5):
>
> If you require this function to run for every user; social, database, or otherwise, then you will need to use a post login Action or a Rule. I would suggest using an Action, as it is the successor to Rules and gives you access to a richer feature-set than Rules (versioning, full npm library, improved logging, etc.). With that said, it is completely possible to achieve this with a Rule as well. Just be aware that rules have access to a [limited set of npm modules](https://auth0-extensions.github.io/canirequire/#aws-sdk) and will be likely deprecated at…

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [August 24, 2021, 9:52pm UTC](https://community.auth0.com/t/aws-sdk-dynamo-db-doesnt-execute-query-in-rules/68416/4 "2021-08-24T21:52:54Z")

</div>

A post was merged into an existing topic: [Auth0 post registration action doesn’t work](https://community.auth0.com/t/auth0-post-registration-action-doesnt-work/68355/6)

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [August 24, 2021, 9:53pm UTC](https://community.auth0.com/t/aws-sdk-dynamo-db-doesnt-execute-query-in-rules/68416/5 "2021-08-24T21:53:01Z")

</div>


