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

Support for CloudWatch Events as event source #52

Closed
rodrigosaito opened this issue Mar 31, 2016 · 3 comments
Closed

Support for CloudWatch Events as event source #52

rodrigosaito opened this issue Mar 31, 2016 · 3 comments

Comments

@rodrigosaito
Copy link
Contributor

I am using this as event source, this is a scheduled event on cloud watch:

event_sources:
  - arn: arn:aws:events:us-east-1:XXXX:rule/some-rule

And getting this error:

ValueError: Unknown event source: arn:aws:events:us-east-1:XXXX:rule/some-rule

I checked the code and CloudWatch events seems to not be implemented as a type of event source.

I can help with a PR if you are able to give me the directions on what I need to do to implement it.

@coopernurse
Copy link
Contributor

I'm interested in this feature too and may take a crack at it on my fork. I'll post an update here if I have something working if others want to help test it.

@coopernurse
Copy link
Contributor

Got something working today. Does kappa own the event sources specified in the file? If so it seems odd to specify the arn in the yml file up front. I deviated slightly from the existing pattern in Context._create_event_sources() and introduced a notion of type - here's the example yaml:

---
name: kappa-cron
environments:
  dev:
    profile: xyz
    region: us-west-2
    event_sources:  
      - type: cloudwatch
        name: hello-cron-dev
        schedule: rate(1 minute)
        description: cron to run this lambda function every minute
        enabled: true
lambda:
  description: Kappa sample lambda that runs every minute
  handler: simple.handler
  runtime: python2.7
  memory_size: 128
  timeout: 3

The add() method does three things:

  • events.put_rule
  • lambda.add_permission
  • events.put_targets

The assumption is that the rule is owned by kappa and can be removed if/when the lambda function is removed.

Any comments on the above? I could revert to the arn convention, but keeping things like the account id out of the yaml file seems good if we can avoid it.

The alternative would look like this (I removed some irrelevant sections for comparison):

---
name: kappa-cron
environments:
  dev:
    event_sources:  
      - arn: arn:aws:events:us-west-2:1234567890:rule/hello-cron-dev
        schedule: rate(1 minute)
        description: cron to run this lambda function every minute
        enabled: true

@coopernurse
Copy link
Contributor

Ok - PR has been filed:

#69

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants