Is there a way to attach a `DockerImageFunction` ...
# help
d
Is there a way to attach a
DockerImageFunction
to a Bucket notification? I’m getting:
Copy code
Type 'DockerImageFunction' is not assignable to type 'FunctionDefinition'.
  Type 'DockerImageFunction' is missing the following properties from type 'Function': _isLiveDevEnabled, localId, attachPermissions, getConstructMetadata ts(2322)
f
Currently
sst.Bucket
only takes
sst.Function
notifications.
That said, you can do this with CDK code:
Copy code
const bucket = new sst.Bucket(...);

const function = // create a DockerImageFunction

bucket.s3Bucket.addEventNotification(s3.EventType.OBJECT_CREATED, new s3n.LambdaDestination(function));
d
Works great. Thanks. As a side question related to DockerImageFunction - Is there some helper to create a role for an array of permissions? DockerImageFunction takes a role as a prop. I can’t specify
permissions: [this.table, this.rds, this.bucket],
like we do for the others functions. I wonder if there is a easy way to use that helper and then to get the role. Currently, we create an sst.Function (that we need and happens to be very similar) and then we set the role
role: myOtherSimilarFunction.role
and it works well
f
Yeah the
permissions: […]
syntax is very specific to SST functions. The workaround you did is probably the best way to go.