serverless/serverless

Streams need to be created before event triggers

yeehaa123 opened this issue · 8 comments

This is a (Bug Report)

Description

For bug reports:

  • What went wrong?

When I try to deploy my templates. I get the following error:

     An error occurred while provisioning your stack: DebugEventSourceMappingKinesisMissingresourcesdev
     - Stream arn:aws:kinesis:us-east-1:774182433398:stream/missing-resources-devdoes
     not appear to be active..

This is due to the fact that the streams are not created yet. I understand that serverless does not create streams for me, but I would expect that they get created before the triggers in the same template

  • What did you expect should have happened?

I expect serverless to create the streams before the event triggers

  • What was the config you used?
  • What stacktrace or error message from your provider did you see?

For feature proposals:

  • What is the use case that should be solved. The more detail you describe this in the easier it is to understand for us.
  • If there is additional config how would it look

Similar or dependent issues:

  • #12345

Additional Data

  Your Environment Infomation -----------------------------
     OS:                 linux
     Node Version:       6.8.0
     Serverless Version: 1.0.3
  • _Serverless Framework Version you're using_:
  • _Operating System_:
  • _Stack Trace_:
  • _Provider Error messages_:

This may be a separate issue, but the same problem also affect the iamRoleStatements. They should also be created before the stream event triggers

This should've been resolved with the fixes we've pushed to the stream event source. Feel free to re-open if this problem persists.

I've also hit this bug with Serverless v1.15.3

............Serverless: Deployment failed!

  Serverless Error ---------------------------------------

  An error occurred while provisioning your stack: ReceiveDataFromGatewayEventSourceMappingKinesisReceive - Stream arn:aws:kinesis:us-east-1:###########:stream/receivedoes not appear to be active..

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Forums:        forum.serverless.com
     Chat:          gitter.im/serverless/serverless

  Your Environment Information -----------------------------
     OS:                     darwin
     Node Version:           6.9.1
     Serverless Version:     1.15.3

Thanks for commenting @justinm 👍

Could you please share your serverless.yml file so that we can look into it?

Thanks @pmuens for getting back to me. I apologize for a delay in my response, but I have created a simple github repo that is reproducing the issue. Please see https://github.com/justinm/serverless-2514

@pmuens, should I create a new issue regarding this? I created a small sample application that's capable of reproducing this issue.

Oh shoot. It looks like this slipped through the cracks. Sorry for that @justinm 😬

So it looks like you're trying to deploy a stream which is not enabled / active. Not 100% sure if this is something related to Serverless or if AWS forces you to only deploy enabled streams.

Could you try to re-deploy with an enabled stream and see if this works?

I've only deployed enabled streams so far (and have disabled them later on).

@justinm I ran into the same error when trying to deploy a new event stream source on an already existing lambda. I got around it my making the lambda depend on the stream, that way it deployed the kinesis stream first before updating the lambda. From your repo, you could try the following for each stream and lambda (see ReceiveDataFromStreamLambdaFunction which is just named after your lambda with "LambdaFunction" appended):

functions:
  receiveDataFromStream:
    handler: index
    events:
      - stream:
          arn: arn:aws:kinesis:${env:AWS_REGION}:${env:AWS_ACCOUNT_ID}:stream/redeye-receive
          batchSize: 100
          startingPosition: LATEST
          enabled: false

resources:
  Resources:
    ReceiveDataFromStreamLambdaFunction:
      Type: AWS::Lambda::Function
      DependsOn:
        - "ReceiveStream"
    ReceiveStream:
      Type: AWS::Kinesis::Stream
      Properties:
        Name: redeye-receive
        ShardCount: 1