https://pulumi.com logo
Title
e

echoing-zebra-28421

06/01/2021, 5:57 PM
Hello everyone. I have a question. Does anyone know how to save an object to DynamoDB? I am doing this:
const notificationTable = new aws.dynamodb.Table(
  "notificationTable",
  {
    readCapacity: 10,
    writeCapacity: 10,
    hashKey: "UUID",
    attributes: [
      {
        name: "UUID",
        type: "S",
      },
    ],
  }
);

const attributes = {
  name: "Name custom",
  item: [{ key: "key-custom", value: "value-custom" }],
};

const obj = {
  UUID: { S: "04b12ed0-b431-11eb-87d6-03d0311066e5" },
  CreatedAt: { S: "2021-05-13T21:20:37.275Z" },
  Event: { S: "custom_events" },
  NamedUser: { S: "<mailto:alex.quintero@gmail.com|alex.quintero@gmail.com>" },
  Attributes: { S: JSON.stringify(attributes) },
  Status: { S: "SEND" },
};

const notificationTableItem = new aws.dynamodb.TableItem(
  "notificationTableItem",
  {
    tableName: notificationTable.name,
    hashKey: notificationTable.hashKey,
    item: `${JSON.stringify(obj)}`,
  }
);
My result is: