Hi team, I took this some aws examples, and I can'...
# aws
q
Hi team, I took this some aws examples, and I can't get lambda working as expected.... especially this line of code
Copy code
const s3 = new aws.sdk.S3();
triggers the issue
Copy code
{
  "errorType": "TypeError",
  "errorMessage": "Cannot read properties of undefined (reading 'S3')",
  "stack": [
    "TypeError: Cannot read properties of undefined (reading 'S3')",
    "    at Runtime.<anonymous> (/var/task/__index.js:14:32)",
    "    at Runtime.__f0 [as handler] (/var/task/__index.js:22:34)",
    "    at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1085:29)"
  ]
}
source code:
Copy code
import * as aws from '@pulumi/aws';

const bucket = new aws.s3.Bucket('bucket');

bucket.onObjectCreated(
  'onNewVideo',
  new aws.lambda.CallbackFunction<aws.s3.BucketEvent, void>('onNewVideo', {
    callback: async bucketArgs => {
      console.log('onNewVideo called');
      if (!bucketArgs.Records) {
        return;
      }

      const s3 = new aws.sdk.S3();
      console.log(s3.apiVersions);

      for (const record of bucketArgs.Records) {
        console.log(
          `*** New video: file ${record.s3.object.key} was uploaded at ${record.eventTime}.`
        );
      }
    }
  })
);