diff --git a/dynamodb/populate-data/lambda/main.py b/dynamodb/populate-data/lambda/main.py index fa4d28c..6030d0c 100644 --- a/dynamodb/populate-data/lambda/main.py +++ b/dynamodb/populate-data/lambda/main.py @@ -76,3 +76,5 @@ def lambda_handler(event, context): "statusCode": 200, "body": json.dumps("200 items successfully inserted into DynamoDB"), } + +lambda_handler("","") \ No newline at end of file diff --git a/dynamodb/populate-data/main.tf b/dynamodb/populate-data/main.tf index 5b0a654..66dbbaa 100644 --- a/dynamodb/populate-data/main.tf +++ b/dynamodb/populate-data/main.tf @@ -1,5 +1,3 @@ - - resource "aws_dynamodb_table" "global_table" { name = var.table_name billing_mode = "PAY_PER_REQUEST" diff --git a/dynamodb/populate-data/script/get_data_dynamodb_stream.py b/dynamodb/populate-data/script/get_data_dynamodb_stream.py new file mode 100644 index 0000000..5b01d3b --- /dev/null +++ b/dynamodb/populate-data/script/get_data_dynamodb_stream.py @@ -0,0 +1,29 @@ +import boto3 + +dynamodb_client = boto3.client('dynamodb') + +# Get the stream ARN from your table +table_name = "MyGT" +response = dynamodb_client.describe_table(TableName=table_name) +stream_arn = response['Table']['LatestStreamArn'] + +print(stream_arn) +# Get the shard iterator +streams_client = boto3.client('dynamodbstreams') +stream_response = streams_client.describe_stream(StreamArn=stream_arn) +shard_id = stream_response['StreamDescription']['Shards'][0]['ShardId'] + +shard_iterator_response = streams_client.get_shard_iterator( + StreamArn=stream_arn, + ShardId=shard_id, + ShardIteratorType='TRIM_HORIZON' +) + +shard_iterator = shard_iterator_response['ShardIterator'] +while True: + records_response = streams_client.get_records(ShardIterator=shard_iterator) + for record in records_response['Records']: + print(record) + + # Update shard iterator for the next loop + shard_iterator = records_response['NextShardIterator']