cdk-constructs
cdk-constructs copied to clipboard
fix(dynamodb-seeder): Correct S3 file stream handling with transformToString
Resolve the issue: https://github.com/cloudcomponents/cdk-constructs/issues/214
Summary
Fixes JSON parsing errors in the DynamoDB seeder by:
- Replacing
body.toString()withtransformToString('utf-8')for proper S3 stream handling
Changes
- Updated
getSeedsFromS3to use AWS SDK v3'stransformToString:- Ensures correct UTF-8 decoding of S3 files
- Prevents malformed JSON errors from stream corruption
Impact
- Fixes
Unexpected tokenerrors when parsing seed files - Maintains backward compatibility with existing S3 buckets/keys
Error Context
Fixes cases where body.toString() corrupted S3 files, causing errors like:
Unexpected token 'o' in JSON at position 1