Quick Bites of Pulumi: Random Provider

Cloud Native Pilgrim | Kubernetes Enthusiast | Serverless Believer | Customer Experience Architect @ Pulumi | (he/him) | CK{A,AD} |
Search for a command to run...

Cloud Native Pilgrim | Kubernetes Enthusiast | Serverless Believer | Customer Experience Architect @ Pulumi | (he/him) | CK{A,AD} |
No comments yet. Be the first to comment.
GPU scheduling in Kubernetes has always felt like buying a mansion when you need a studio apartment. A small inference workload that needs 2GB of GPU memory gets scheduled on an entire 80GB A100, and there's nothing you can do about it. The device pl...

TL;DR: The code https://github.com/dirien/quick-bites Nothing is more controversial in the Kubernetes community than whether to use Helm or Kustomize. I always advocate the philosophy of using the right tool for the right job. It avoids the problem...

TL;DR Le code https://github.com/dirien/quick-bites Introduction This article is part three of my series on secret management on Kubernetes with the help of Pulumi. In my first article, we talked about the Sealed Secrets controller. The second arti...

With AWS Lambda

Disaster Recovery, Data Migration made easy!

https://github.com/dirien/quick-bites
This is a very quick overview of the Random Provider from Pulumi, similar to the Quick Bites of Cloud Engineering videos from Laura Santamaria (@nimbinatus)

The Random Provider is on of many providers that come with Pulumi. Currently, it implements the following functions:
I will show you three of them in more detail.

Do you want also this cool names, like when you start a docker container? Or don't want to set a name for your k8s cluster or virtual machines? Then this function is definitely for you.
Just call the function NewRandomPet and you will get a random pet name! Simplez!
Here is a golang example:
serverName, err := random.NewRandomPet(ctx, "pet-server-name", &random.RandomPetArgs{})
ctx.Export("serverName", serverName.ID())
And the output is:
serverName: "correct-turkey"

I love RandomShuffle. It is a function that is great to do random permutation of a list of strings. Set the ResultCount
for the number of results to return. With the argument Seed you can set the seed for the random number generator.
vmSize, err := random.NewRandomShuffle(ctx, "vm-size", &random.RandomShuffleArgs{
Inputs: pulumi.StringArray{
pulumi.String("Standard_DS12-1_v2"),
pulumi.String("Standard_DS3_v2_Promo"),
pulumi.String("Standard_D4_v3"),
pulumi.String("Standard_E8d_v4"),
},
ResultCount: pulumi.Int(2),
})
ctx.Export("vmSize", vmSize.Results)
And the output is:
vmSize: [
[0]: "Standard_DS12-1_v2"
[1]: "Standard_D4_v3"
]

Last but not least, the RandomUuid function. The classic UUID generator for literally anything and everything.
uuid, err := random.NewRandomUuid(ctx, "random-uuid", nil)
ctx.Export("uuid", uuid.Result)
voilà, the output is:
uuid: "cc222078-6b73-b35a-970c-974e331a9ede"
Try this provider for yourself, in your next Pulumi project!
You can find more information about the Random Provider
