Describe the bug
I want to use an externally created bucket as an event notification source for a lambda
Expected Behavior
An IBucket can be used as the notification source
Current Behavior
Type errors. An IBucket cannot be assigned to a Bucket.
Reproduction Steps
import * as core from "aws-cdk-lib";
import * as event_sources from "aws-cdk-lib/aws-lambda-event-sources";
import * as s3 from "aws-cdk-lib/aws-s3";
const app = new core.App()
const ibucket = s3.Bucket.fromBucketName(app, "IBucket", "IBucket");
const eventSource = new event_sources.S3EventSource(ibucket, {events: [s3.EventType.OBJECT_CREATED]})
TS2345: Argument of type 'IBucket' is not assignable to parameter of type 'Bucket'.
Possible Solution
Since addEventNotification is the only method used by S3EventSource and is available on an IBucket, I think it should be safe to loosen the type restriction to IBucket.
Coercing the type and deploying works.
Additional Information/Context
No response
CDK CLI Version
2.40.0
Framework Version
No response
Node.js Version
16
OS
OSX
Language
Typescript
Language Version
No response
Other information
No response
Describe the bug
I want to use an externally created bucket as an event notification source for a lambda
Expected Behavior
An IBucket can be used as the notification source
Current Behavior
Type errors. An
IBucketcannot be assigned to aBucket.Reproduction Steps
Possible Solution
Since
addEventNotificationis the only method used by S3EventSource and is available on an IBucket, I think it should be safe to loosen the type restriction to IBucket.Coercing the type and deploying works.
Additional Information/Context
No response
CDK CLI Version
2.40.0
Framework Version
No response
Node.js Version
16
OS
OSX
Language
Typescript
Language Version
No response
Other information
No response