Curious whether anyone has been able to create an ...
# help
g
Curious whether anyone has been able to create an S3 bucket with notification to SQS? When I try
Copy code
const incomingBucket = new s3.Bucket(this, 's3Incoming', {
      bucketName: `${scope.stage}-data-files`,
      removalPolicy: cdk.RemovalPolicy.DESTROY,
    });
    const incomingQueue = new sqs.Queue(this, 'sqsIncoming', {
      queueName: `${scope.stage}-incoming`
    });
    incomingBucket.addObjectCreatedNotification(incomingQueue);
I get the following error:
Copy code
Error: ENOENT: no such file or directory, open 'app/.build/lib/lambda/index.py'
    at Object.openSync (node:fs:582:3)
    at Object.readFileSync (node:fs:450:35)
    at new NotificationsResourceHandler (app/node_modules/@aws-cdk/aws-s3/lib/notifications-resource/notifications-resource-handler.ts:87:29)
    at Function.singleton (pp/node_modules/@aws-cdk/aws-s3/lib/notifications-resource/notifications-resource-handler.ts:41:16)
    at BucketNotifications.createResourceOnce (app/node_modules/@aws-cdk/aws-s3/lib/notifications-resource/notifications-resource.ts:105:52)
    at BucketNotifications.addNotification (app/node_modules/@aws-cdk/aws-s3/lib/notifications-resource/notifications-resource.ts:54:27)
    at Bucket2.addEventNotification (app/node_modules/@aws-cdk/aws-s3/lib/bucket.ts:338:24)
    at Bucket2.addObjectCreatedNotification (app/node_modules/@aws-cdk/aws-s3/lib/bucket.ts:343:17)
    at new MyStack (app/lib/MyStack.js:26:20)
It looks like CDK needs to create a lambda to connect the notification, but SST hasn’t added it to the build? I would do this directly with SST but it seems that Lambda functions are the only notification type supported from sst.Bucket.
f
Hey @Guy Shechter, I can take a look at this later today and put in support for S3 bucket notification > SQS.
Does that work for you timeline wise?
g
Sounds great. In the meantime I just implemented the notification manually in the console.
f
Hey @Guy Shechter, added Queue notifications for S3 buckets in v0.34.0. You can do something like:
Copy code
const myQueue = new Queue(this, "MyQueue");

new Bucket(this, "Bucket", {
  notifications: [myQueue],
});
More examples here - https://docs.serverless-stack.com/constructs/Bucket#configuring-queue-notifications