hi, does anyone use F# with Pulumi?
# dotnet
n
hi, does anyone use F# with Pulumi?
t
several folks do. @wet-noon-14291 has been very active, also @shy-garage-48328 I believe
n
Thanks. I wrote a library to use more idiomatic F# for Pulumi APIs. Computational expressions for resources and for the Output<T> monad. It made the code much cleaner and I would appreciate some feedback. I would also like to use code generators to auto-create CEs from Pulumi assemblies so it will not require high maintenance.
t
Iā€™d love to take a look!
šŸ‘ 1
w
I was thinking about that, but decided to go for simpler helper functions while playing around. Mainly to make it easier for non native F# speakers to better understand since they would see the types as in the docs.
šŸ‘ 1
n
hope it's OK to put the link here: https://github.com/UnoSD/Pulumi.FSharp.Azure
on the README.md there are example resources. it looks really clean compared to constructors + xxxArgs objects.
and using the
output {}
or
secretOutput {}
, you can avoid using
Output.Tuple
and a long chain of
Apply
with a nicer do notation. But I just added the resources I needed for another project so it misses basic stuff such as VMs, VNET, etc... I need to learn a bit of Myriad to avoid having to do the repetitive task of adding operations for all properties. I did what I could generalizing resourceGroup and names to a base type, but each resource has different properties so I end up repeating a lot of code for those and there is no way to avoid it without code generation.
E.G. to be able to support passing the resource group both as a name string, as an object an as an Output<>, I had to write 3+ overloads.
t
If you ever want to generate the full API surface, this is the source that we use internally https://github.com/pulumi/pulumi-azure/blob/master/provider/cmd/pulumi-resource-azure/schema.json
As a bonus, Iā€™d likely get all non-Azure SDKs too
w
If you are interested I have my POC online https://github.com/mastoj/sweetspot. Not the most beautiful code in the world since Iā€™m just trying out different things at the same time :)
n
thank you @tall-librarian-49374, I may look into that instead of using reflection over the types
thank you @wet-noon-14291 I will also explore your repository
w
Your CE looks really sweet.
n
thanks šŸ™‚
w
@tall-librarian-49374 for the kubernetes part, is it this schema that is used to generate the types: https://raw.githubusercontent.com/pulumi/pulumi-kubernetes/master/provider/cmd/pulumi-resource-kubernetes/schema.json
t
yes
šŸ‘ 1
n
@tall-librarian-49374 thank you for the schema, that was really useful, I can already generate a builder from that for Virtual Machines, I'm trying to make it compatible with all resources now
t
magic!
šŸ˜ 1
w
another question about the schema @tall-librarian-49374, it looks like the schema format is the same for both kubernetes and azure, just different content. Is that correct? If it is it shouldn't be too hard to use the same generator to generate CE for kubernetes as well.
t
yes, the format is universal for all providers, current and future ones