Mysterious error (TypeError: Value is not an object: undefined) when using kinesis with aws-sdk

I have a realm function that’s meant to send data to an aws kinesis data stream. Third party services have been deprecated in favor of using external dependencies so I installed v2 of the aws-sdk (v3 apparently doesn’t work based on this thread, added my secrets for the IAM user, and tried to use the realm function. This is the test case I used:

    const AWS = require('aws-sdk');

    // Configure AWS SDK with the credentials created before
    // You should probably use a .env file for this
    AWS.config.update({
        region: 'us-east-1',
        accessKeyId: context.values.get('AWS_KINESIS_ACCESS_KEY_ID'),
        secretAccessKey: context.values.get('AWS_KINESIS_SECRET_ACCESS_KEY'),
    });

    // Create a kinesis client
    const kinesisClient = new AWS.Kinesis();
        kinesisClient.putRecord(
            {
                Data: JSON.stringify(changeEvent.fullDocument),
                StreamName: KINESIS_STREAM_NAME,
                PartitionKey: '1',
            },
            (err, data) => {
                if (err) {
                    console.log('kinesis error:', JSON.parse(err));
                    throw err;
                }
                console.log('kinesis success:', data);
            }
        );

This gave the error TypeError: Value is not an object: undefined. The error only went away if I commented out the entire call to putRecord. To work around this I went back to using the third-party service and adding a rule for kinesis, and that worked. However given that third-party services will no longer be available at the end of this year, that’s not a reliable solution. Any ideas as to what the problem with the aws-sdk may be? I haven’t found anything concrete elsewhere.