Conversation
| new FunctionlessProject({ | ||
| parent: turbo, | ||
| defaultReleaseBranch: "main", | ||
| name: "cron", | ||
| outdir: "packages/cron", | ||
| cdkVersion: "2.39.1", | ||
| devDeps: ["@types/node-fetch"], | ||
| deps: ["node-fetch"], | ||
| }); |
There was a problem hiding this comment.
Curious if we should use the template instead?
There was a problem hiding this comment.
Push this with projen and then eject the whole package later?
There was a problem hiding this comment.
Is it hard to just run yarn create functionless and move the readme and code into it? I also noticed that the readme talked about the template. If it's a pain that's fine but if not I would vote do it now.
There was a problem hiding this comment.
I think the current turbo harness relies on projects running projen. I think all or nothing here is the best. Lets eject everything at the same time.
| import { App, Duration, Stack } from 'aws-cdk-lib'; | ||
| import { Schedule } from 'aws-cdk-lib/aws-events'; | ||
| import { EventBus, Function } from 'functionless'; | ||
| import fetch from 'node-fetch'; | ||
|
|
||
| const app = new App(); | ||
| const stack = new Stack(app, 'functionlessCron'); | ||
|
|
||
| const job = new Function(stack, 'cronJob', async () => { | ||
| const metaphors = await fetch('http://metaphorpsum.com/sentences/5').then( | ||
| (x) => x.text(), | ||
| ); | ||
| console.log(metaphors); | ||
| }); | ||
|
|
||
| EventBus.schedule(stack, 'cron', Schedule.rate(Duration.minutes(1))).pipe(job); |
There was a problem hiding this comment.
Lol I was scrolling through the example - so many files from projen. And then this tiny cute example ❤️
| @@ -0,0 +1,105 @@ | |||
| # Create a Cron Job with Functionless | |||
There was a problem hiding this comment.
Great model to follow of writing a readme for each.
|
|
||
| The Cron Job will use [AWS EventBridge's](https://aws.amazon.com/eventbridge/) scheduled rules to trigger a job in a lambda [Lambda Functions](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html). | ||
|
|
||
| Then we'll deploy and test the application. |
There was a problem hiding this comment.
This was a little bit abrupt. Maybe put the steps in a numbered list
|
|
||
| Then we'll deploy and test the application. | ||
|
|
||
| To see the completely application, go [here](https://github.com/functionless/functionless-samples/packages/cron). |
| ## Create an new app | ||
|
|
||
| > yarn create functionless |
There was a problem hiding this comment.
The example code doesn't use this - should we make sure it does?
Also this isn't a code block
There was a problem hiding this comment.
Was going to ask if the code should be using the template. It would be nice to keep dogfooding the template just to discover if anything is off.
| const metaphors = await fetch("http://metaphorpsum.com/sentences/5").then( | ||
| (x) => x.text() | ||
| ); |
There was a problem hiding this comment.
Curious why you chose to use the .then api
|
|
||
| This create a rule which executes any targets every minutes. Lets give it something to do. | ||
|
|
||
| ## Metaphors on the Minute |
There was a problem hiding this comment.
I don't understand this heading?
There was a problem hiding this comment.
Stupid joke. The API I'm using returns metaphors.
|
|
||
| ## Metaphors on the Minute | ||
|
|
||
| A scheduled rule is just an Event Bridge rule and an event bridge rule can trigger many different things. For now, we'll trigger a lambda function. |
There was a problem hiding this comment.
Maybe link to the relevant documentation
|
|
||
| ## Permissions | ||
|
|
||
| But wait, when do I create policies and permissions for my resources to talk to each other? |
There was a problem hiding this comment.
Perhaps:
You may have noticed we never explicitly created any IAM policies.
| EventBus.schedule(stack, "cron", Schedule.rate(Duration.minutes(1))); | ||
| ``` | ||
|
|
||
| This create a rule which executes any targets every minutes. Lets give it something to do. |
There was a problem hiding this comment.
Consider:
"An EventBus Scheduled Rule emits a triggering event at a rate specified by the duration argument. In this example, we'll emit an event every minute. These triggers can be used to trigger downstream integrations (e.g. AWS Lambda, AWS Step Functions, etc.)."
I would also probably kill the next section and just introduce what you will be triggering.
No description provided.