Hey everyone,
I am getting an error trying to add a custom permission on a function in the serverless.ts config. This works fine in serverless.yaml
With serverless-iam-roles-per-function installed (version 3.0.1), I have the following (see commented out section with iamRoleStatements):
...
functions: {
foo: {
handler: 'foo.handler',
events: [
{
eventBridge: {
eventBus: ‘myArn’
pattern: {
source: [‘logging.service'],
},
},
},
],
// iamRoleStatements: [
// {
// Effect: 'Allow',
// Action: ['dynamodb:PutItem'],
// Resource: [
// {
// 'Fn::GetAtt': ['LoggingTable', 'Arn'],
// },
// ],
// },
// ],
},
...
}
Here is an excerpt of the compilation error message when iamRoleStatements is enabled:
Type '{ handler: string; description: string; events: { eventBridge: { eventBus: string; pattern: { source: string[]; }; }; }[]; iamRoleStatements: never[]; }' is not assignable to type '{ name?: string | undefined; events?: ({ __schemaWorkaround__: null; } | { schedule: string | { rate: string; enabled?: boolean | undefined; name?: string | undefined; description?: string | undefined; input?: string | ... 2 more ... | undefined; inputPath?: string | undefined; inputTransformer?: { ...; } | undefine...'.
Object literal may only specify known properties, and 'iamRoleStatements' does not exist in type '{ name?: string | undefined; events?: ({ __schemaWorkaround__: null; } | { schedule: string | { rate: string; enabled?: boolean | undefined; name?: string | undefined; description?: string | undefined; input?: string | ... 2 more ... | undefined; inputPath?: string | undefined; inputTransformer?: { ...; } | undefine...'.ts(2322)
Does anybody knows a workaround for this issue?
Thanks
–
Serge