6 ms·
Pulumi is really a royal piece of shit. Why the f*ck am I writing code to do "deployment". In C# --> new Dictionary<string, object> when dealing with a values
by jmspring 2y ago
Pulumi is really a royal piece of shit. Why the f*ck am I writing code to do "deployment". In C# --> new Dictionary<string, object> when dealing with a values.yaml for instance. The whole need to figure out when and when not to use Apply.
Give me Terraform (as much as I hate it) any day.
- stackskipton 2y agoAs SRE dealing with former Pulumi, "Hey Devs can use code to deploy infrastructure" is not great idea you think it is. I've seen some real ugly conditional behavior where I'm like "Is this or is this not going to run? I honestly can't tell."
- hinkley 2y agoWe had so much conflict with the ops team over their choice of Terraform. The three colors of variable thing is just fucking bonkers. Getting tests wrapped around it that actually did what we thought they meant was a giant pain in the ass. I won't go as far as to say we burned bridges arguing back and forth about it but they were definitely significantly singed. Config files simply don't work until they do. And if it's your job to stare at them for hours and hours a day then maybe that's okay with you, but if you expect other people to 'just learn' it you're an idiot or an asshole. Or both. Ain't nobody got time for magic incantations. I also think it should tell you you're on the wrong path when your app is named after a verb and the data it deals with is all declarative.
- darkstar_16 2y agoEver thought that "Ops" needs a different mindset than the devs are used to ?
- deleted 2y ago[deleted]
- hinkley 2y agoAnd that’s why we don’t delegate that work to devs.
- slillibri 2y agoHonestly curious, I've been writing terraform for a while but I have never heard of "The three colors of variable thing". Could you expand on that?
- skywhopper 2y agoThey mean var vs local vs from-a-resource. There are some places you can’t use some types of variables. It can be annoying but it’s not really a huge problem if you design your approach with that in mind. The worst part is that the Terraform team at Hashicorp often excuse not fixing these design issues as “safety measures” which isn’t entirely untrue but when over half of your users want something, sometimes you should get over yourself. For what it’s worth, OpenTofu is fixing many of these sorts of things that cause people pain. But my advice is to learn to use the tool. Terraform has such great benefits (in the right use cases). If you’re struggling, either you are missing something or you chose the wrong tool for your particular job. Either way, don’t gripe that this specialized tool for infra management doesn’t work exactly like every other general purpose programming language.
- slillibri 2y agoThat makes sense I guess, I just never considered locals or data resources as variables.
- 878654Tom 2y agoSame, locals are in my head like consts. You define it and it stays that way. A shortcut for a repeated value. Data resources are you requesting a dynamic value of your environment. Variables are dynamic values that a user can change.
- hinkley 2y agoThat’s only the case if you spend all day rerunning deployments. If your task is more frequently to transition the cluster config from A -> B then the distinction blurs and you go from a 10:1 delta ratio of the different classes of state to maybe 3:2, at which point it feels like splitting hairs. Especially if the locals vary between prod and pre-prod, and worse if dev sandboxes end up with per-user instances, which for us was mercifully only needed for people working on the TF scripts, so we could run our tests locally.
- salmo 2y agoHonestly, the culture/org structure is a way bigger problem in this story than any proper noun tool. If you’re ignoring guidance and patterns and getting mad reinventing the wheel, that’s on dev. If “ops” mandates tooling and doesn’t have any skin in the game, that’s on them. And both problems are on your leadership. If y’all just hate each other and don’t listen or participate, then you can’t be successful. It is ironic that this is the pattern that the devops movement landed us in.
- pjmlp 2y agoSeconded, as someone that really does developer / operations, depending on the project assignment, I have learned the hard way that infrastructure configuration code should be as declarative as possible. Sure "use code to deploy infrastructure" sounds great, and that is why we get stuff like Ant, Gradle, Pulumi, Jenkins Groovy scripts, .NET Aspire,.... until someone has to debug spaghetti code on a broken deployment.
- AtlasBarfed 2y agoOn the flip side dsl declarative stuff is obfuscated magic that you can't step through or drive into. a dsl like SQL involves one basic substrate (data organized in tables) that you can compile in your head. But declarative infra as code involves a thousand different things across a dozen different clouds. Declarative will hold off spaghetti for... A bit. But it devolves to spaghetti as well (think fine grained acls, or places where order of operations, which the dsl does not specify and is magically resolved, becomes ambiguous). And if you need to go off the reservation (dsl support doesn't exist or is immature for rapidly evolving platforms, need some custom postprocess steps) then you are... What? Probably writing code and scripts to autoinvoke on the new node, phone home to a central.... Yup that's code. Finally, declarative code has an implicit execution loop. But for something like iac that is a very complicated, the execution loop that isn't well documented. And some committed changes to declarative code May trigger a destructive pass followed by a possibly broken constructive phase. It's a tough problem.
- cruffle_duffle 2y ago> Give me Terraform (as much as I hate it) any day Terraform sure is a quirky little DSL ain’t it? It’s so weirdly verbose. But at the same time I can create some azure function app, setup my GitHub build pipeline, get auth0 happy and in theory hook up parts of stripe all in one system. All those random diverse API’s plumbed together and somehow it manages to work. But boy howdy is that language weird.
- paulgb 2y agoYeah. I guess maybe terraform makes sense if the people writing it spend enough of their time writing HCL to master it, but I ported our terraform config to Pulumi a few years ago and never looked back. It meant I could spend way less time googling for the HCL way to do something (say, templated resource) and just use the JS primitives I already know.
- hinkley 2y ago>spend enough of their time writing HCL to master it Making Terraform changes every six weeks was enough time that we forgot everything and had to refresh our memories. Every time it felt like going into the water in a northern beach and forgetting how goddamned cold the water was, then reproaching yourself for forgetting.
- rwiggins 2y agoI haven't used Terraform in years (because I changed jobs, not because of the tech itself), but back in the day v0.12 solved most of my gripes. I have always wished they'd implement a better "if" syntax for blocks, because the language itself pseudo-supports it: https://github.com/hashicorp/terraform/issues/21512 https://github.com/hashicorp/terraform/issues/21512 But yeah, at $previous_job, Terraform enabled some really fantastic cross-SaaS integrations. Stuff like standing up a whole stack on AWS and creating a statuspage.io page and configuring Pingdom all at once. Perfect for customers who wanted their own instance of an application in an isolated fashion. We also built an auto-approver for Terraform plans based on fingerprinting "known-good" (safe to execute) plans, but that's a story for a different day.
- Hawxy 2y agoAs much as I like it, I find C# to be too inflexible of a language for infrastructure code. I tried with Pulumi for a while but moved to TypeScript as it works so much better. Structural typing makes your life a lot easier.
- MrLeap 2y agoI bounce back and forth between javascript and C# depending on the nature of the job at hand. I'm curious what things you'd like to do with C# that you can't? I find that with some handwringing, C# can be forced to do almost anything. between extension methods, dispatch proxies and reflection you can pummel it into basically any shape. Having to write a little boilerplate to make it happen can be a drag though. I do sometimes wish C# had something from a blank project that let me operate with as much reckless abandon as Object.assign does in js land.
- Hawxy 2y agoIt's not the fault of the language, it's just the nature of infrastructure code that's been ported from terraform. With Pulumi C# you end up with multiple nested objects/dictionaries with a load of `new` object calls that just add noise to your codebase. There's also some pain points with some types being Input<T> which IDEs try to autocomplete when in reality you need to call `new T()`. Typescript permits structural typing that _feels_ a lot better to write and read within this context. I use C# extensively for most other things I do, but this the one area where I prefer not to use it.
- klysm 2y agoApply is really straightforward. The dictionary stuff is very annoying overhead but it’s nice keeping everything in one language.
- postalrat 2y agoWhy are people templating yaml for terraform like they templated html in php in 1996?
- benatkin 2y agoBecause it works fine, and is also used in for other things like Helm Charts? https://helm.sh/docs/chart_template_guide/control_structures/ https://helm.sh/docs/chart_template_guide/control_structures...
- jnsaff2 2y agoHelm charts are a horrible example of text based templating. You have YAML/JSON that k8s API wants, that is fed through helm which is fed through helmsman or whatever newer thing. There might be a layer or two of other templating around. Sometimes companies have built systems so developers/devops don't even have the ability to see what the final compiled version of the template is which is like the mother of all: "works on my laptop" problems. It's super easy to break text based templating because of some space, tab, string escaping or whatever. YAML makes it worse as there are lots of gotchas and different ways of doing. JSON, being quite verbose and inflexible at least has strong structure right in your face so it's a bit easier to figure out what went wrong. With a proper programming language data structure you can be much better with verifying that the things you add or remove or iterate over will produce a valid result, much better refactoring and working as a team independently.
- arkh 2y ago> Helm charts are a horrible example of text based templating. Every time I see " | nindent whatever" I'm asking why the fuck the tool cannot manage indentation.
- kevincox 2y agoAnd it breaks every time a variable gets a `:` inside of it and now you are producing invalid yaml everywhere you forgot to call `| toYaml`.
- arkh 2y agoTried Pulumi thinking "it's gonna abstract all the k8s specifics". Welp no, still need to know and understand K8s so I still don't see the value from those kind of tools. In which case why not use something like Pkl to generate my yaml from some sensible code-like structures?
- katdork 2y agokubernetes is very complex and therefore any abstraction which completely glosses over the way the underlying systems work would make it very hard to avoid leaking or a bad abstraction to begin with. the complexity in one way or another must be preserved within the abstraction (in all likelihood) or you will have cases you cannot create in that layer or breakages which now have the total complexity of both the abstraction itself AND kubernetes itself required to fix. i would not say IaC is going to provide you a magic solution to learning k8s, although the value in using IaC (e.g. Argo CD / Flux CD + Kustomize + ...) in K8s land is that you are no longer imperatively managing your cluster resources and therefore can keep them within a repository, managed like code. the point of the solution is not to make it easier for newcomers, but to make it easier to have teams manage and work together on an established cluster for deployments, ... in the case of Pulumi, you leverage the single language with typechecking instead of relying upon K8s flavoured YAML, which is itself beneficial in many ways (since you can use your regular developer tooling) wrt pkl, pretending K8s manifest structure underneath does not help because you will need to know how the keys within a manifest interact with the underlying system regardless, especially to understand functionality, e.g. node selectors, taints and tolerations, node affinity, ... i prior managed a terraform-based deployment of several k8s clusters and it still required knowledge of those keys and values, alongside knowledge of the underlying resource types. without those you can't implement things like GPU-based node selection for jobs which require a GPU, ...
- Longwelwind 2y agoI would agree with you, if HCL wasn't a bad language in itself: * You can't make have variables in an import block (for example, to specify a different "id" value for each workspace) * There is no explicit way to make a resource conditional based on variables. Only a hacky way to do that using "count = foo ? 1 : 0" * You can't have variables in the backend configuration, making it impossible to store states in different places depending on the environment. * You can't have variables in the "ignore_changes" field of a resource, making it impossible to dynamically ignore changes for a field (for example, based on module variables). * The VSCode extension for HCL is slow and buggy. Using TS with pulumi or TFCDK makes it possible to use all the existing tooling of the language.
- breendreams 2y agoFor Terraform, most of the issues with conditionals can be resolved by creating dictionaries dynamically and looping through it to generate resources. You get the bonus of controlling the resource id and being able to selectively delete resources without worrying about ordering.
- cyberpunk 2y agoThis massively depends on your provider code. Using loops to manage tf stuff can you you into really “fun” scenarios when you want to e.g delete an openstack firewall rule from the middle of the array. I’ve been burned so many times here that I hate all of this stuff with an extreme passion. Crossplane seems to be a genuinely better way out but there are big gotchas there also like resources that can simply never be deleted
- rusty-jules 2y agoWhat about pulumi's declarative yaml interface which can be exported from type-safe languages like cue? https://www.pulumi.com/blog/extending-pulumi-languages-with-yaml-cue-jsonnet-rust/ https://www.pulumi.com/blog/extending-pulumi-languages-with-...
- nuker 2y ago> Give me Terraform (as much as I hate it) any day. Just use CloudFormation. Easy to write, declarative, vars (Parameters and Output exports). Trick is not to pile everything in one Stack. Use several.
- notyourwork 2y agoCDK is much better to express this. Why cfn?
- nuker 2y agoLess lines, easier to read, declarative (cdk is interactive, less predictable). And it generates shitty CFN, we can do better ourselves :)
- notyourwork 2y agoHow is cdk interactive? I use cdk and have it auto build and deploy.
- nuker 2y agoIt is "imperative", not interactive, sorry. From Wiki: "There are generally two approaches to IaC: declarative (functional) vs. imperative (procedural). The difference between the declarative and the imperative approach is essentially 'what' versus 'how'." https://en.wikipedia.org/wiki/Infrastructure_as_code#Types_of_approaches https://en.wikipedia.org/wiki/Infrastructure_as_code#Types_o...