I’ve recently been approached about potentially publishing an Infrastructure as Code book. While I certainly have plenty of ideas, I wanted to get a general sense of what do actual practitioners need to learn in order to be successful with IAC?
I was thinking to have 3 parts to the book, 1 that focuses on executive leadership and tells the “why” story of IAC, 1 that focuses on the technical implementation of IAC, and the last that focuses on architectural patterns and use cases. What are your thoughts about this structure?
How did your organization adopt IAC? Did it start with the cloud? What does your maturity journey look like?
What’re the most common pitfalls you’ve run across trying to do IAC? Are you able to do full automation or are there still manual steps?
Much appreciated! To follow up on automate it, the make manual changes hard… how have you seen this in practice? For example, if i’m the platform owner for AWS and need to create sub accounts for app dev teams… to start I might create one manually to get them started and get out of the way… then I might write my first terraform script to provision account #2… more than likely I hard coded something so I need to evolve that repo to allow more inputs/etc over time..
So my question to you is: Does that logic/flow of how IAC evolve make sense? How do you avoid that and start with the automation first?
Effectively, yes. The tools are opinionated and I find it best to simply apply it’s best practices. I’ve seen a lot of “let’s get fancy and wrap it with custom process X”, which often is counter to the roadmap of the tool. At least now in 2020 there’s enough feature-full tools out there this shouldn’t be as much of a thing.
So let me phrase this a little different, for provisioning IAC I have to externalize my environment specific code (configuration as code). Same with my application code, I may have environment variables to pass (configuration as code). This is different (in my mind) than infrastructure as code as IAC is solely focusing on the network, servers, firewall, etc. And I want to use the same IAC to provision multiple environments. Do you agree in that differentiation? Second question, how do you test configuration code differently than IAC? IE my IAC may create a security group but the CaC defines the name and i want it to comply with a naming standard.
In my experience, as an engineering leader, IAC is a cultural transformation and a change of job as much as it’s a thing people need to learn. The best analogy is to TDD – it’s counter-intuitive at first. It also changes the nature of the engineering team’s work – the first few iterations, it feels like nothing is happening, because engineers like to write code, not write declarative stuff that builds infrastructure on which nothing happens.
As an engineering leader, letting people explore & practice in katas and workshops and then immediately apply in practice, letting people greenfield rather than brownfield, and making sure you build the first iterations light on features so you can assemble the right learning is super important. “Hello world” first – build a simple API that does nothing, and automate the stack, then add to something that works.
As an individual learning, I think the most important advice is “just do it” – grit your teeth and work through all the super frustrating stuff, learn the stack inside and out (Terraform or Cloudformation or CDK or …), and insist on automating the whole thing. Like everything else, small steps and immediate feedback is best.
You also need some confidence that you amortize the benefits over time & it gets easier and more fun. (I think many of us have forgotten the feeling of learning how to program the first time – it’s like that).
Great response thank you. I’m sure you know there will be those that say this is unacceptable. If I’m CTO and the business needs an app delivered in 6 months, I can’t say we need 3 months first to build out the IaC. Its pretty common too then to “half-ass” IaC as you go along or accept manual deployments. Those are things the business don’t care about. Also, if I have to pay to unskill my current staff, why not just pay for consulting to do this for me? How would you respond to that criticism or prevent those discussions from happening?
Write your deployment pipeline for your tool of choice and template it.
Develop a bootstrapping account procedure for whatever you choose to call a ‘workload’ (I suggest workload)
Don’t deploy infra yourself (except supporting services in your workloads that provide a platform), give them a pipeline to deploy infra safely to their accounts. Safely means Iam is thought about. Template boundary policies, scoped IAM perms for ‘typical’ tasks. Extensible pipeline roles so teams can propose their own IAM policies to increase their perms via a merge request to a central authority.
Providing a landing zone for other teams is a daunting and comprehensive task if you have no experience. Doing it with no prior experience is a 2+ year journey. I’m on my second large client and it’s much easier, but still a huge task.
We don’t allow engineers write access at console at all (EDIT IN PROD OR PROD LIKE ENVIRONMENTS!!). This evolved our pipelines so fast and brought so much consistency to the org it wasn’t funny. Manual changes should be difficult to get approved.
The guy you are responding to was posting gold and has obvious experience.
Start small. Don’t try to automate everything all at once. Pick discrete pieces and automate them. This reduces the effort to manageable parts and also helps you encourage loose coupling of components.
On the cultural side, this can be a massive shift for some, especially ops folks in specialty areas. I’ve had complications trying to convince DBA teams that their expertise is not going to waste, but instead of day 2 support work, their efforts will be much more involved in initial architectural and platform discussions.
What kind of issues have you had to overcome by not allowing developers write access to the console? I’ve seen dev teams given 1 account per environment. They have write access in dev but not prod obviously. However, the platform team provisions accounts does not provide the deployment pipeline so that’s been up to devs themselves to figure out which obviously has led to a nonstandard mess.
When you say start small, can you go into more detail? What do you mean? Are we talking about for new development in the cloud or enhancing existing application on-prem?
It depends on the shop, tbh. If your team has skills in devops and automation, I’d advise starting that process with new applications and only working on existing on-prem once you’ve really established a good internal model. If the team is just toe-dipping into automation, creating replicas of existing apps, as tests, would be helpful in understanding how automation eases the pain of development and deployment.
In either case, I feel that it’s best to pick one piece to automate first, maybe a set of unit tests or one part of a build, set a concrete goal and an expected outcome. If it’s vague, you won’t really know whether you’ve been successful or when you’re done.
usually devs are ok with programattic access. so, provided you can have an extensible IAM system that they can assume using automation you’ll be sort of OK.
the biggest things you need are
developers with buy-in to security
actual developers (developers that want console access in prod are shit)
the ability to take time automating IAM and policies etc. (This is REAL HARD)
you mentioned a non standard mess. We deliver a terraform templated pipeline for infrastructure creation as ‘first thing’.
most of the time, they want to build something like kubernetes or ecs then deliver application level stuff to it. Terraform plus whatever they build is usually quite great for this.
Serverless/SAM whatever tends to go more in the cloudformation direction or away from terraform anyway. We are still figuring this out a bit, but the same credential for Terraform conveys the same perms which they could use. Its more tricky around the compliance part at this point, as our terraform piplines are good with guard rails. A cloudformation that we don’t control via a pipeline could essentially deploy a non encrypted ebs volume for example to an ec2 instance. Which is sad face for compliance (I work for enterprise)
Note that all the stuff i’m saying relates to bringing an enterprise into the cloud so i’m a lot more concerned with complinance and safety than a startup would be.
but ‘templating’ is the greatest thing I’ve ever discovered in IT in the last 3 years. I knew it was a thing, but I hadn’t realised how far you can take that concept. Check out cookiecutter (python project) everything can look the same. Pipelines, accounts, IAM whatever. it’s all files, it can all be abstracted and variablized.
I only care about the enterprise so how do developers who have no aws experience do dev work? Let’s say their building a Java app to run in a container on ECS… you have a template for this? How did you get that template standard in the beginning without some manual trial and error? Who is responsible for troubleshooting pipeline errors? Let’s say i push to a ecr repo but have the wrong iam permissions.
You need to deliver incrementally. Keeping the first sprints light doesn’t mean delivering nothing. That probably means being deliberately simple, limiting the primitives you build on, & doing lots of “basic and works”.
As for business benefit, the benefit is lower expense on operations and maintenance leading to greater product profitability and a greater %age of engineering time going to growth rather than maintenance.
There are two patterns here: just do it & don’t tell anyone, or invest in transformation.
Our method was to give them a pipeline that does ‘nothing’ but runs terraform.
We supply an interface
lint: (terraform fmt and terraform validate plus enforce a naming convention with regex)
test: (run tests against tf, check for faults like non encrypted volumes)
build: (output a plan)
those guys need to be able to write resources and get those resources through that local pipeline.
merging to master and tagging it will then do the deployment after the pipeline of course does the same checks and also checks that local build matches pipeline build.
So there ends ‘my’ responsiblity. we have safely ensured that a developer can ‘learn’ aws.
NOW, the ‘platform’ team or ‘devops bros’ or whatever you want to call them could now (time and prio permitting) look at the business and write a terraform module to ‘deploy ecs thing’ or ‘deploy standard ec2 instance’ or whatever and encourage/document other teams to use it. Or accept and review MRs for modules that the devs contribute back to…
We also copy what aws does. you know the ‘shared responsibility’ model they have? stack on top of that. Developer shouts that they can’t work your pipeline, look at the pipeline and see if it’s broken. Is it? push a change. Did they not know how aws works? recommend training!
of course politics, coaching and not being a dick go hand in hand with all of this, but so far, we have found it a very very good way to slowly coach large enterprises into a more ‘devops’ way of working.
the mind shift from ‘team asks central infra team for server’ mentality is a problem though, this needs to come from the top.
I agree with making it hard to change things without going through IAC.
For technical reasons, there are things developers have to create “manually” in our production account and then might need to make manual changes to. Nothing critical and if for some reason it needs to be recreated it just a slight hassle. For those, we have given them CloudFormation permission to only run those templates and we have a quick create link for them.
Everything else has to be created with CloudFormation on every account except for DEV and goes through our deployment pipeline.
Anything that couldn’t be created with CF like adding keys to our DDB config table and creating Mysql users is done with custom resources.