Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to use dynamodb stream trigger with exported stream ARN and configValidationMode="error" #209

Open
LouisPinsard opened this issue May 24, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@LouisPinsard
Copy link
Contributor

Description

Hello !

I am using lift 1.17.0 and serverless 3.17.0.
I used the single table construct to deploy a dynamodb table and I am now trying to trigger a lambda function with the dynamodb stream of the table.

The event key for my function :

events: [
    {
      stream: {
        type: 'dynamodb',
        arn: '${construct:myTable.tableStreamArn}',
      },
    },
  ],
};

In my serverless configuration, I have configValidationMode: 'error',

I have the following error when deploying :
Error: Configuration error at 'functions.dispatchEvents.events.0.stream': unsupported string format

It works well when I use configValidationMode: 'warn', the lambda and the trigger are well deployed and working

How to Reproduce

service: my-app
configValidationMode: error
provider:
    name: aws

plugins:
    - serverless-lift

functions:
    myFunc:
        handler: './handler.main'
        events:
            - stream:
                type: dynamodb
                arn: ${construct:myTable.tableStreamArn}

constructs:
    myTable:
        type: database/dynamodb-single-table

Additional Information

No response

@LouisPinsard LouisPinsard added the bug Something isn't working label May 24, 2022
@fredericbarthelet
Copy link
Collaborator

Thanks for reporting this issue @LouisPinsard :)

Digging around a little bit with your exemple serverless.yml, I've found out that at the time of Serverless Framework validation, the service definition input - or at least solely the myFunc.events[0].stream - passed into ajv validator has the following value { type: 'dynamodb', arn: '${Token[TOKEN.194]}' }

This indeed does not validate against the framework JSON Schema definition as it's neither a CloudFormation intrinsic function, neither a string starting with arn:. The ${Token...} string is a CDK placeholder, that will be resolved at later stage.

One of those stage is the variable resolver called on ${construct:...} occurrences in the service file definition. However, the current observation would led to believe variable resolution actually happens after service file validation, which I find really strange. It is also strange that similar issues were not submitted on Lift earlier to emphasize this problem, I'm guessing the arn property from stream event type has a much stronger typing than other places where ${construct:...} variable resolver is usually used.

This might be worth asking around on https://github.com/serverless/serverless side to check if we can have their input on this issue. Would you care opening a linked issue on their side referencing this one ?

In the meantime, I implemented a small PR showcasing this issue in Lift unit tests suite.

@jcranendonk
Copy link

Serverless says it's Lift 🤷 Sounds like we're in a catch-22.

@cmcnicholas
Copy link
Contributor

Resurrecting this one, is there anything I can do as an investigation to help support moving this on?

With serverless 4, the default is going to be set to "error" for config issues so lift will fail immediately with the documented approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants