# Serverless-iam-roles-per-function and serverless.ts

**URL:** <https://forum.serverless.com/t/serverless-iam-roles-per-function-and-serverless-ts/13462>\
**Category:** Serverless Framework\
**Tags:** aws\
**Created:** [December 22, 2020, 6:54pm UTC](https://forum.serverless.com/t/serverless-iam-roles-per-function-and-serverless-ts/13462 "2020-12-22T18:54:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sdeby](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@sdeby](https://forum.serverless.com/u/sdeby)\
**Post date:** [December 22, 2020, 6:54pm UTC](https://forum.serverless.com/t/serverless-iam-roles-per-function-and-serverless-ts/13462/1 "2020-12-22T18:54:14Z")

</div>

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):

```auto
...
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:

```auto
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

---

<div class="post-metadata">

**Author:** ![pdeltour](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@pdeltour](https://forum.serverless.com/u/pdeltour)\
**Post date:** [January 15, 2021, 9:32am UTC](https://forum.serverless.com/t/serverless-iam-roles-per-function-and-serverless-ts/13462/2 "2021-01-15T09:32:18Z")

</div>

Hi Serge,

i add the same issue and founded that adding a // @ts-expect-error  
compilation directive stopped the compiler from screaming.

```
// @ts-expect-error: Let's ignore a single compiler
  iamRoleStatements: [
    {
      'Effect': 'Allow',
      'Action': ['s3:GetObject', 's3:ListBucket'],
      'Resource': 'arn:aws:s3:::myfavoritebucket/*'
    }

```

It seems the problem is general for all the additional structures added by plugins.

It is a bit of a hack so any better options would be appreciated.

Best

Pierre
