StreamViewType

class aws_cdk.aws_dynamodb.StreamViewType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

When an item in the table is modified, StreamViewType determines what information is written to the stream for this table.

See:

https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_StreamSpecification.html

ExampleMetadata:

infused

Example:

import aws_cdk.aws_lambda_event_sources as eventsources
import aws_cdk.aws_dynamodb as dynamodb

# fn: lambda.Function

table = dynamodb.Table(self, "Table",
    partition_key=dynamodb.Attribute(
        name="id",
        type=dynamodb.AttributeType.STRING
    ),
    stream=dynamodb.StreamViewType.NEW_IMAGE
)

fn.add_event_source(eventsources.DynamoEventSource(table,
    starting_position=lambda_.StartingPosition.LATEST,
    metrics_config=lambda.MetricsConfig(
        metrics=[lambda_.MetricType.EVENT_COUNT]
    )
))

Attributes

KEYS_ONLY

Only the key attributes of the modified item are written to the stream.

NEW_AND_OLD_IMAGES

Both the new and the old item images of the item are written to the stream.

NEW_IMAGE

The entire item, as it appears after it was modified, is written to the stream.

OLD_IMAGE

The entire item, as it appeared before it was modified, is written to the stream.