serverless-iam-roles-per-function icon indicating copy to clipboard operation
serverless-iam-roles-per-function copied to clipboard

Adding disableLogs: true to lambda config makes plugin throw an error

Open markgibaud-vtail opened this issue 3 years ago • 3 comments

Hi there,

I have the following config in Serverless.yml for a lambda:

asyncSyncProductsDb:
    handler: functions/asyncSyncProductsDb/asyncSyncProductsDb.main
    timeout: 300
    memorySize: 2048
    events:
       //eventbridge event source
    iamRoleStatements:
      - Effect: Allow
        Action:
          - ssm:GetParameters
          - ses:SendEmail
        Resource:
          - '*'

Now I want to temporarily disable creation of the log group, in order to later re-enable & recreate it in a nested stack using serverless-plugin-split-stacks custom config. However when I add disableLogs: true as per the docs I get an error:

asyncSyncProductsDb:
    handler: functions/asyncSyncProductsDb/asyncSyncProductsDb.main
    disableLogs: true
    timeout: 300
    memorySize: 2048
    events:
       //eventbridge event source
    iamRoleStatements:
      - Effect: Allow
        Action:
          - ssm:GetParameters
          - ses:SendEmail
        Resource:
          - '*'
Serverless Error ----------------------------------------

  serverless-iam-roles-per-function: ERROR: Function Resource is not in expected format. For function name: asyncSyncProductsDb

The plugin is throwing this error even though my lambda config is fine.

If I comment out the iamRoleStatements then it works fine and deletes the log group, ostensibly because this plugin does not process the lambda config.

Any ideas on fixes or workarounds? I need to do this to about 30 lambdas :-)

markgibaud-vtail avatar Mar 16 '22 13:03 markgibaud-vtail

My plugins order, in case that helps!

plugins:
  - serverless-webpack
  - serverless-export-env
  - serverless-appsync-plugin
  - serverless-plugin-datadog
  - serverless-prune-plugin
  - serverless-step-functions
  - serverless-iam-roles-per-function
  - serverless-plugin-split-stacks
  - serverless-plugin-git-variables

markgibaud-vtail avatar Mar 16 '22 15:03 markgibaud-vtail

Any update on this? We're running into the same problems... :/

drobakowski avatar May 30 '22 10:05 drobakowski

Since the original maintainer is the only one holding the keys to both fix the builds that are failing and being able to publish to NPM and seems to have abandoning this I've taken the steps to workaround this and is currently publishing this in a parallell plugin named serverless-iamroles.

The fork can be found here: https://github.com/andersquist/serverless-iam-roles-per-function

I've also made a PR to fix this specfic issue if you want to take a look as mentioned above.

andersquist avatar Jun 04 '22 12:06 andersquist