Saturday, March 20, 2021

aws DynamoDB

Tables, Items, and Atributes

Tables, Items, and Atributes are the core components

Tables, a colletion of items. 

Items, a collection of atrributes.  Each item in the table has a unique identifier, or primary key, that distinguishes the item from all of the others in the table. Other than the primary key, each item can have its own distinct attributes, which means that neither the attributes nor their data types need to b e defined beforehand.

Attributes, each item is composed of one or more attributes, this is the fundamental data element.  Most of the attributes are scalar, which means that they can have only one value.

Primary Key

DynamoDB supports two different kinds of primary keys:

  • Partition Key - A simple primary key, composed of one attribute known as the partition key.
  • Partiion key and sort key - Referred to as a composite primary key, composed of two attributes. The first attribute is the partition key, and the second attribute is the sort key.
Secondary Indexes

Your can create one or more secondary indexes on a table. A secondary index lets you query the data in the table using an alternate key, in addition to queries against the primary key.

Two kinds of indexes:
  • Global secondary index - An index with a partition key and sort key that can be different from those o the table.
  • Local secondary index - An index that has the same partition key as the table, but a different sort key.
Each table has a quote of 20 global secondary indexes and 5 local secondary indexes per table.

DynamoDB Streams

DynamoDB Streams is an optional feature that captures data modification events in DynamoDB tables. The data about these events appear in the stream in near-real time, and in the order that the events occurred.

Each event is represented by a stream record. If you enable a stream on a table, DynamoDB Streams writes a stream record whenever one of the following events occurs:

  • A new item is added to the table: The stream captures an image of the entire item, including all of its attributes.
  • An item is updated: The stream captures the "before" and "after" image of any attributes that were modified in the item.
  • An item is deleted from the table: The stream captures an image of the entire item before it was deleted.

Each stream record also contains the name of the table, the event timestamp, and other metadata. Stream records have a lifetime of 24 hours; after that, they are automatically removed from the stream.

S3 replication cross region to another account

preparation create the above buckets in two AWS accounts source: leo-functions destination: leo-functions-rep Create IAM role in source acco...