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

CRON scheduled functions #147

Closed
tj opened this Issue Jan 25, 2016 · 13 comments

Comments

Projects
None yet
7 participants
@tj
Member

tj commented Jan 25, 2016

Seems like they don't provide an API for this yet which is a little weird, hopefully that's coming:

@kapilt

This comment has been minimized.

Show comment
Hide comment
@kapilt

kapilt Jan 26, 2016

Collaborator

there's sort of a usable shim for it in the cloud watch events service which allows cron spec invocation of target lambda function

ie. https://github.com/boto/botocore/blob/develop/botocore/data/events/2014-02-03/service-2.json#L689

Collaborator

kapilt commented Jan 26, 2016

there's sort of a usable shim for it in the cloud watch events service which allows cron spec invocation of target lambda function

ie. https://github.com/boto/botocore/blob/develop/botocore/data/events/2014-02-03/service-2.json#L689

@johannesboyne

This comment has been minimized.

Show comment
Hide comment
@johannesboyne

This comment has been minimized.

Show comment
Hide comment
@johannesboyne

johannesboyne Jan 27, 2016

Contributor

@tj Ok, I've found a solution, checkout: johannesboyne@95d8383

svcc := cloudwatchevents.New(session.New())
svcl := lambda.New(session.New())

cronEvent := &Cron{
    Name:              "CronTestLambda",
    Description:       "Test",
    Expression:        "rate(5 minutes)",
    FunctionName:      "<function-name>",
    FunctionArn:       "arn:aws:lambda:us-west-2:<...>",
    CloudWatchService: svcc,
    LambdaService:     svcl,
}

err := cronEvent.AddSchedule()
log.Println(err)

What do you think, where should this belong, how would the command invocation would look like?
I thought about sth. like

  • apex cron [functionname] "rate(5 minutes)"
  • apex schedule [functionname] "rate(5 minutes)"
Contributor

johannesboyne commented Jan 27, 2016

@tj Ok, I've found a solution, checkout: johannesboyne@95d8383

svcc := cloudwatchevents.New(session.New())
svcl := lambda.New(session.New())

cronEvent := &Cron{
    Name:              "CronTestLambda",
    Description:       "Test",
    Expression:        "rate(5 minutes)",
    FunctionName:      "<function-name>",
    FunctionArn:       "arn:aws:lambda:us-west-2:<...>",
    CloudWatchService: svcc,
    LambdaService:     svcl,
}

err := cronEvent.AddSchedule()
log.Println(err)

What do you think, where should this belong, how would the command invocation would look like?
I thought about sth. like

  • apex cron [functionname] "rate(5 minutes)"
  • apex schedule [functionname] "rate(5 minutes)"
@tj

This comment has been minimized.

Show comment
Hide comment
@tj

tj Jan 27, 2016

Member

niceee! I was thinking just a property in the function.json might be cool, nice to have it in code, I think I'd maybe go with "schedule" as the property, but cron might be more familiar

Member

tj commented Jan 27, 2016

niceee! I was thinking just a property in the function.json might be cool, nice to have it in code, I think I'd maybe go with "schedule" as the property, but cron might be more familiar

@johannesboyne

This comment has been minimized.

Show comment
Hide comment
@johannesboyne

johannesboyne Jan 27, 2016

Contributor

Oh yes, that's maybe even better!

{
  "name": "foo",
  "description": "pretty description",
  "runtime": "golang",
  "memory": 128,
  "timeout": 5,
  "role": "<...>",
  "schedule || cron": "rate(5 minutes)"
}
Contributor

johannesboyne commented Jan 27, 2016

Oh yes, that's maybe even better!

{
  "name": "foo",
  "description": "pretty description",
  "runtime": "golang",
  "memory": 128,
  "timeout": 5,
  "role": "<...>",
  "schedule || cron": "rate(5 minutes)"
}

@tj tj removed the pending AWS support label Jan 27, 2016

@johannesboyne

This comment has been minimized.

Show comment
Hide comment
@johannesboyne

johannesboyne Jan 27, 2016

Contributor

IMHO apex/event_sources/cron should be the apex package, because cron is the "tool" that "schedules" and scheduling is an Event Source (AWS terminology):
kind of:

who schedules  what is the schedule
cron rate(5 minutes)

But inside the function.json it is:

"schedule": "rate(5 minutes)"

because it represents the schedule value.
Does this make any sense? :D

Contributor

johannesboyne commented Jan 27, 2016

IMHO apex/event_sources/cron should be the apex package, because cron is the "tool" that "schedules" and scheduling is an Event Source (AWS terminology):
kind of:

who schedules  what is the schedule
cron rate(5 minutes)

But inside the function.json it is:

"schedule": "rate(5 minutes)"

because it represents the schedule value.
Does this make any sense? :D

@tj

This comment has been minimized.

Show comment
Hide comment
@tj

tj Jan 27, 2016

Member

./sources/cron skips the _ :D

I'd maybe put the bulk of the code in that package, and then call it in a "cron" plugin, similar to these: https://github.com/apex/apex/tree/master/plugins, using a DeployHook.

That way we keep most of these integrations out of Function methods.

I suppose we should think about config more now too:

{
  "sources": {
    "schedule": "rate(5 minutes)"
  }
}

But most will have multiple properties, so maybe we should always make them objects

Member

tj commented Jan 27, 2016

./sources/cron skips the _ :D

I'd maybe put the bulk of the code in that package, and then call it in a "cron" plugin, similar to these: https://github.com/apex/apex/tree/master/plugins, using a DeployHook.

That way we keep most of these integrations out of Function methods.

I suppose we should think about config more now too:

{
  "sources": {
    "schedule": "rate(5 minutes)"
  }
}

But most will have multiple properties, so maybe we should always make them objects

@johannesboyne

This comment has been minimized.

Show comment
Hide comment
@johannesboyne

johannesboyne Jan 27, 2016

Contributor

Ok, so kind of this direction:
johannesboyne@35f831b

Will just have to add

  • function.json parsing
  • propper invocation through the deploy hook
  • prop. refactoring
Contributor

johannesboyne commented Jan 27, 2016

Ok, so kind of this direction:
johannesboyne@35f831b

Will just have to add

  • function.json parsing
  • propper invocation through the deploy hook
  • prop. refactoring

@tj tj modified the milestone: v0.6.0 Jan 28, 2016

@mthenw mthenw assigned mthenw and unassigned mthenw Jan 29, 2016

@mthenw mthenw added the in progress label Jan 29, 2016

@tj tj removed this from the v0.6.0 milestone Feb 4, 2016

@tj

This comment has been minimized.

Show comment
Hide comment
@tj

tj Feb 4, 2016

Member

closing for now since I'm not sure it's the road we should be going down. In an ideal world we just supported all of AWS without a secondary tool but that's a ton of work and that is basically TF

Member

tj commented Feb 4, 2016

closing for now since I'm not sure it's the road we should be going down. In an ideal world we just supported all of AWS without a secondary tool but that's a ton of work and that is basically TF

@tj tj closed this Feb 4, 2016

@marwanhilmi

This comment has been minimized.

Show comment
Hide comment
@marwanhilmi

marwanhilmi Feb 23, 2016

Sorry to ping a closed issue, but is there anyway this is currently possible or are the TF changes required first? I'm assuming worst case scenario I can modify the function from the Lambda control panel to run on a schedule?

marwanhilmi commented Feb 23, 2016

Sorry to ping a closed issue, but is there anyway this is currently possible or are the TF changes required first? I'm assuming worst case scenario I can modify the function from the Lambda control panel to run on a schedule?

@tj

This comment has been minimized.

Show comment
Hide comment
@tj

tj Feb 23, 2016

Member

@marwanhilmi I think the next release of TF adds it: hashicorp/terraform#4986

Member

tj commented Feb 23, 2016

@marwanhilmi I think the next release of TF adds it: hashicorp/terraform#4986

@mthenw mthenw removed the in progress label Feb 24, 2016

@joelcox

This comment has been minimized.

Show comment
Hide comment
@joelcox

joelcox Sep 30, 2017

Looks like this feature actually landed in terraform. I don't have much experience with go nor terraform, but I might have a stab is this if somebody points me in the right direction :-)

joelcox commented Sep 30, 2017

Looks like this feature actually landed in terraform. I don't have much experience with go nor terraform, but I might have a stab is this if somebody points me in the right direction :-)

@rv-rsouza

This comment has been minimized.

Show comment
Hide comment
@rv-rsouza

rv-rsouza Jan 24, 2018

Hey guys! Is there plan on implementing this in next release?

rv-rsouza commented Jan 24, 2018

Hey guys! Is there plan on implementing this in next release?

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