Live data from Hacker News

Rethinking Infrastructure as Code from Scratch

nathanpeck.com

61–70 of 124 posts

Re: Rethinking Infrastructure as Code from Scratch

#61
post #55

Earlier quoted context omitted.

You just described the role of Terraform. HCL is very JSON like and human readable

fwiw, you can write Terraform in JSON too. Not recommending it, but it's equivalent.

Yea HashiCorp talks about it but also does not recommend it

Re: Rethinking Infrastructure as Code from Scratch

#62

this is great, but I would argue the biggest issue with infrastructure as code is this: the structure and syntax for AWS is entirely different from Azure is entirely different from GCP. Instead of abstracting to CSS, I would argue modeling what Bytecode did in java for multi-operating system, we should do for infrastructure of code. That way, you could easily replicate in different environments, free yourself from ve…

You don't want vendor lock-in. The vendor, however, has different incentives---why would they want to prevent lock-in to their service?

Re: Rethinking Infrastructure as Code from Scratch

#63
The CSS like IaC language idea was not what I was expecting. It seems ok, but I was hoping for something deeper. What I mean is that I have always felt like there is tension or a mismatch between IaC and the underlying services in a more general sense. I’ve used CDK, Pulumi, Terraform, and CloudFormation and you can argue the merits of each. But they all kind of suck in the sense that you are programming a machine that was not really designed to be programmed. Sure AWS and all the rest have APIs to call and IaC is a decent abstraction over those APIs, but imagine if instead they exposed some lower level interface designed to execute IaC programs natively. I feel like that is the ultimate path to IaC that feels like actual programming.

Re: Rethinking Infrastructure as Code from Scratch

#64
post #60

Earlier quoted context omitted.

You can do that through abstraction. You “include” your Terraform Azure Provider or Terraform AWS Provider. At the end of the day, your module needs to know what it’s interacting with but not the higher level of abstraction. We have done it at my work to make it cloud agnostic just in case we need to go to another CSP

> We have done it at my work to make it cloud agnostic just in case we need to go to another CSP Have you actually tested migrating Cloud Providers with your cloud-agnostic infrastructure?

Yes we tested it with Azure Stack Hub and AWS Outposts

Re: Rethinking Infrastructure as Code from Scratch

#65

I don't think the author has tried Pulumi, which can do exactly this kind of thing.

He's suggesting something closer to Pulumi than a declarative (Cloudformation, Terraform), but with more of an inheritance model to apply blanket attributes to the targeted resources. This is possible with Pulumi but requires a lot of boilerplate and some monkeypatching.

Re: Rethinking Infrastructure as Code from Scratch

#66
post #63

The CSS like IaC language idea was not what I was expecting. It seems ok, but I was hoping for something deeper. What I mean is that I have always felt like there is tension or a mismatch between IaC and the underlying services in a more general sense. I’ve used CDK, Pulumi, Terraform, and CloudFormation and you can argue the merits of each. But they all kind of suck in the sense that you are programming a machine th…

> The CSS like IaC language idea was not what I was expecting

I took it as a clumsy (yet somehow descriptive) analogy.

Re: Rethinking Infrastructure as Code from Scratch

#67

> I believe that infrastructure as code languages and tool assisted generators that we currently use are good, and they are taking steps in the right direction, but most of them are trying to patch over underlying complexity in a way that is fundamentally unscalable. Sure, I can get behind this. Yesterday I was trying to figure out how to give a name to EC2 instances generated by AWS-managed autoscaler group that’s c…

> “there’s no way it has to be like this.” It really doesn't, but alas: worship at the altar of unnecessary cloud complexity or be cast out to the on-prem Elysian field.

I think you've muddled "Elysian fields" (the reward of heroes) with "being put out to pasture" (superannuation).

Re: Rethinking Infrastructure as Code from Scratch

#68

Earlier quoted context omitted.

You can do that through abstraction. You “include” your Terraform Azure Provider or Terraform AWS Provider. At the end of the day, your module needs to know what it’s interacting with but not the higher level of abstraction. We have done it at my work to make it cloud agnostic just in case we need to go to another CSP

How did you approach testing this? Anything to watch out for when defining abstractions? I'm following Crossplane's abstraction model.

So we start with terraform fmt -check, terraform validate, and terraform plan.

Contract tests are used

Then we have test resources that get created, validated then instantly destroyed.

If we don’t have access to the CSP, then we can only go as far as contract tests. I can’t integrate with it live such as GCP.

Starting to look into Terratest.

Re: Rethinking Infrastructure as Code from Scratch

#69
post #11

My problem with the current IAS systems is the state storage. It should not be needed! Instead, the IAS tool should introspect the systems it's managing and build the necessary state on the fly.

This does not work. Say I have resource A with property X=1 I define in IAC. Someone comes along and modifies X=2 outside of state. With your way, the IAC tool would see that change and think it was naturally part of the desired state, whereas stored state will catch the drift. And before anyone says “well dont modify outside of IAC” I say 1) that’s often impractical and 2) sometimes automation can modify resources o…

First, you can guard against it. Just periodically re-run the infra code in the "dry-run" mode (from a CI/CD system) and scream if you see any differences.

Second, this is still fine. Don't make changes outside of the IAC control. And if you do make them, retro-fix the IAC files until there is no diff with the actual state.

Third, IAC should have an option to ignore some changes.

> Also, dynamically creating state creates all sorts of concurrency issues, which is another nice thing about stored state, you can put a lock on it.

In my experience, this is not a big issue in practice. Production deployments should be done through some kind of CI/CD, and it naturally serializes builds.

However, nothing stops you from adding locking without doing the full state management.

Re: Rethinking Infrastructure as Code from Scratch

#70
post #24

this is great, but I would argue the biggest issue with infrastructure as code is this: the structure and syntax for AWS is entirely different from Azure is entirely different from GCP. Instead of abstracting to CSS, I would argue modeling what Bytecode did in java for multi-operating system, we should do for infrastructure of code. That way, you could easily replicate in different environments, free yourself from ve…

"This is what I want from infrastructure as code and I have yet to see it." If you sit down with the terraform specifications for an AWS instance, a GCP instance, and an Azure instance, and start trying to write that harmonization, you will rapidly discover why for yourself. Even just trying to specify a network setup and putting an instance on the public internet is impossible to harmonize, without making something…

Exactly. If you want portability across clouds, Terraform ain't it. The only way I know of to achieve that right now (for any reasonably complex architecture) is:

- Minimal amount of Terraform to deploy Kubernetes (which is different for each cloud provider)

- Helm (or similar) for deploying to Kubernetes

But then you have Kubernets to deal with.

Post reply on HN