Consider introducing a cloud.Function abstraction
See original GitHub issuei.e. instead of having APIs like:
export declare function cron(name: string, cronTab: string, handler: Action): void;
we would have:
export declare function cron(name: string, cronTab: string, handler: cloud.Function): void;
users would then invoke this by doing:
cloud.timer.cron(..., new cloud.Function({ function: async () => {
// code to run in aws lambda, or azure function
}});
Pros:
- Clearer separation between code that runs at deploy time, and the code we want to eventually run at runtime. Aka: self-documenting.
- Stronger ability to catch certain types of issues at pulumi/lint time. (i.e. we could lexically catch users making resources inside of these cloud functions). It would likely not be foolproof. But would help catch a broad set of errors.
- Closer programming model to what we have with tasks. i.e. today you do
cloud.timer.cron(..., new cloud.Task(..., { function: ... ] ]). Now the programming model for functions running in Lambdas vs Containers is more similar. - Better for teaching/explaining what is going on. Today, our examples are so simple that it just looks like a basic app that runs and doesn’t do anything special. With this split it becomes more obvious “ohhhh, all these functions are running as separate lambdas… but, omg, they all get to party on this ‘table’, which just looks like a variable in source”.
- Easier to configure lambdas in the case users need to. for example
new cloud.Function( { memory: 256, function: () => { ... } }). (see https://github.com/pulumi/pulumi-cloud/issues/121)
Cons:
- verbosity. Though my gut tells me it would be isolated. I think it would help people better structure their code to decide what would be partitioned into a particular lambda.
- Superfluousness. As our existing programming model demonstrates, we don’t actually need this. There are also existence proofs for similar systems that also avoid this sort of explicit separation in code. For example, lambdas in C# are either delegates, or become Expression trees. If i write
table.Where(c => ... )what i get is completely dependent on the types of the variables involved, and may not be clear just from perusing the code. This may be a good or bad thing depending on who you talk to 😃 - Less “magical”. But maybe there are enough good things about this that that’s acceptable.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:12 (12 by maintainers)
Top Results From Across the Web
Abstractions and serverless - SoftwareMill Tech Blog
Recovering the abstraction yml descriptor, which fully describes the whole service. It contains details on the provider (as serverless.com can ...
Read more >Why Is It So Tough to Make a Useful Cloud Abstraction?
Lack of API standardization means abstracting away an underlying IaaS provider is much easier said than done.
Read more >Cloud Functions overview - Google Cloud
Cloud Functions provides a connective layer of logic that lets you write code to connect and extend cloud services. Listen and respond to...
Read more >Serverless: The next level of abstraction. | by Nawaz Dhandala
Cloud Provider would take care of installing and maintaining OS, patching it underneath ... Think of serverless as an abstraction over PaaS.
Read more >Understand cloud abstraction for your IT needs - TechTarget
Let's examine each cloud abstraction option and consider the benefits ... For example, code, workflows and test data created in one PaaS is ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Agree 👍. I put in M9 because I’d like to see us do this “soon”. IMHO, one of the highest priority things to do in our cloud framework backlog, given the widescale impacts.
/cc @CyrusNajmabadi
Closing as #573 is covering this now.