github.com/Foodji/aws-lambda-go@v1.20.2/events/dynamodb.go (about)

     1  // Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
     2  
     3  package events
     4  
     5  // The DynamoDBEvent stream event handled to Lambda
     6  // http://docs.aws.amazon.com/lambda/latest/dg/eventsources.html#eventsources-ddb-update
     7  type DynamoDBEvent struct {
     8  	Records []DynamoDBEventRecord `json:"Records"`
     9  }
    10  
    11  // DynamoDbEventRecord stores information about each record of a DynamoDb stream event
    12  type DynamoDBEventRecord struct {
    13  	// The region in which the GetRecords request was received.
    14  	AWSRegion string `json:"awsRegion"`
    15  
    16  	// The main body of the stream record, containing all of the DynamoDB-specific
    17  	// fields.
    18  	Change DynamoDBStreamRecord `json:"dynamodb"`
    19  
    20  	// A globally unique identifier for the event that was recorded in this stream
    21  	// record.
    22  	EventID string `json:"eventID"`
    23  
    24  	// The type of data modification that was performed on the DynamoDB table:
    25  	//
    26  	//    * INSERT - a new item was added to the table.
    27  	//
    28  	//    * MODIFY - one or more of an existing item's attributes were modified.
    29  	//
    30  	//    * REMOVE - the item was deleted from the table
    31  	EventName string `json:"eventName"`
    32  
    33  	// The AWS service from which the stream record originated. For DynamoDB Streams,
    34  	// this is aws:dynamodb.
    35  	EventSource string `json:"eventSource"`
    36  
    37  	// The version number of the stream record format. This number is updated whenever
    38  	// the structure of Record is modified.
    39  	//
    40  	// Client applications must not assume that eventVersion will remain at a particular
    41  	// value, as this number is subject to change at any time. In general, eventVersion
    42  	// will only increase as the low-level DynamoDB Streams API evolves.
    43  	EventVersion string `json:"eventVersion"`
    44  
    45  	// The event source ARN of DynamoDB
    46  	EventSourceArn string `json:"eventSourceARN"`
    47  
    48  	// Items that are deleted by the Time to Live process after expiration have
    49  	// the following fields:
    50  	//
    51  	//    * Records[].userIdentity.type
    52  	//
    53  	// "Service"
    54  	//
    55  	//    * Records[].userIdentity.principalId
    56  	//
    57  	// "dynamodb.amazonaws.com"
    58  	UserIdentity *DynamoDBUserIdentity `json:"userIdentity,omitempty"`
    59  }
    60  
    61  type DynamoDBUserIdentity struct {
    62  	Type        string `json:"type"`
    63  	PrincipalID string `json:"principalId"`
    64  }
    65  
    66  // DynamoDBStreamRecord represents a description of a single data modification that was performed on an item
    67  // in a DynamoDB table.
    68  type DynamoDBStreamRecord struct {
    69  
    70  	// The approximate date and time when the stream record was created, in UNIX
    71  	// epoch time (http://www.epochconverter.com/) format.
    72  	ApproximateCreationDateTime SecondsEpochTime `json:"ApproximateCreationDateTime,omitempty"`
    73  
    74  	// The primary key attribute(s) for the DynamoDB item that was modified.
    75  	Keys map[string]DynamoDBAttributeValue `json:"Keys,omitempty"`
    76  
    77  	// The item in the DynamoDB table as it appeared after it was modified.
    78  	NewImage map[string]DynamoDBAttributeValue `json:"NewImage,omitempty"`
    79  
    80  	// The item in the DynamoDB table as it appeared before it was modified.
    81  	OldImage map[string]DynamoDBAttributeValue `json:"OldImage,omitempty"`
    82  
    83  	// The sequence number of the stream record.
    84  	SequenceNumber string `json:"SequenceNumber"`
    85  
    86  	// The size of the stream record, in bytes.
    87  	SizeBytes int64 `json:"SizeBytes"`
    88  
    89  	// The type of data from the modified DynamoDB item that was captured in this
    90  	// stream record.
    91  	StreamViewType string `json:"StreamViewType"`
    92  }
    93  
    94  type DynamoDBKeyType string
    95  
    96  const (
    97  	DynamoDBKeyTypeHash  DynamoDBKeyType = "HASH"
    98  	DynamoDBKeyTypeRange DynamoDBKeyType = "RANGE"
    99  )
   100  
   101  type DynamoDBOperationType string
   102  
   103  const (
   104  	DynamoDBOperationTypeInsert DynamoDBOperationType = "INSERT"
   105  	DynamoDBOperationTypeModify DynamoDBOperationType = "MODIFY"
   106  	DynamoDBOperationTypeRemove DynamoDBOperationType = "REMOVE"
   107  )
   108  
   109  type DynamoDBSharedIteratorType string
   110  
   111  const (
   112  	DynamoDBShardIteratorTypeTrimHorizon         DynamoDBSharedIteratorType = "TRIM_HORIZON"
   113  	DynamoDBShardIteratorTypeLatest              DynamoDBSharedIteratorType = "LATEST"
   114  	DynamoDBShardIteratorTypeAtSequenceNumber    DynamoDBSharedIteratorType = "AT_SEQUENCE_NUMBER"
   115  	DynamoDBShardIteratorTypeAfterSequenceNumber DynamoDBSharedIteratorType = "AFTER_SEQUENCE_NUMBER"
   116  )
   117  
   118  type DynamoDBStreamStatus string
   119  
   120  const (
   121  	DynamoDBStreamStatusEnabling  DynamoDBStreamStatus = "ENABLING"
   122  	DynamoDBStreamStatusEnabled   DynamoDBStreamStatus = "ENABLED"
   123  	DynamoDBStreamStatusDisabling DynamoDBStreamStatus = "DISABLING"
   124  	DynamoDBStreamStatusDisabled  DynamoDBStreamStatus = "DISABLED"
   125  )
   126  
   127  type DynamoDBStreamViewType string
   128  
   129  const (
   130  	DynamoDBStreamViewTypeNewImage        DynamoDBStreamViewType = "NEW_IMAGE"          // the entire item, as it appeared after it was modified.
   131  	DynamoDBStreamViewTypeOldImage        DynamoDBStreamViewType = "OLD_IMAGE"          // the entire item, as it appeared before it was modified.
   132  	DynamoDBStreamViewTypeNewAndOldImages DynamoDBStreamViewType = "NEW_AND_OLD_IMAGES" // both the new and the old item images of the item.
   133  	DynamoDBStreamViewTypeKeysOnly        DynamoDBStreamViewType = "KEYS_ONLY"          // only the key attributes of the modified item.
   134  )