From the course: Microservices Security Workshop: From Build to Production

How microservices made security better

- We just talked about how microservices made security worse. Now let's talk about how they can make it better. This isn't to say that securing microservices is easy. The challenges are still very real, but just like the shift to cloud, the move to microservices gave us new opportunities, not just for enhancing performance and scale, but for building better security into our software. With great power comes great opportunities. First, everything is code now. If you don't have a development background, this can feel really, really scary, but it helps, I promise. This is the biggest win that everything from infrastructure to dependencies is clearly defined as code. This allows us to set standards across the organization and get accurate auditing done before things are even deployed. Before, infrastructure was pretty manual and full of what's often called click ops. Developers might request a server, and then you'd have someone on the infrastructure team spend a few days or a few hours spinning things up. There was no standardization, no audit trail, no way to reproduce or test changes safely. It was tribal knowledge held together with bash scripts and luck. The bandaid was that at least there was a human in the loop. Now, infrastructure is defined in terraform. Pipelines are defined in YAML. Security policies become custom modules. Everything is fully defined in advance. That shift has made everything auditable, testable, and most importantly, scalable. You don't need to beg teams to, "Please, follow security best practices." You can instead bake them into reusable templates and shared pipeline logic. You can fail build on secrets, require the use of prebuilt components, and catch issues before they ever hit production. In the best-case scenario, security is able to join the DevOps revolution. In the pre-microservice world, security was the blocker. In the days of waterfall and giant quarterly releases, security often came in at the end of the dev cycle with a 200-page report and a PDF full of high-severity findings. Microservices helped to change that. Because services are smaller and more isolated and ephemeral, we can scan them faster, more frequently, with tighter feedback loops. Static analysis, dynamic analysis, container scanning, dependency checks, all of it is easier to automate and contextualize. You don't have to scan the whole monolith or even all of the code at once. Instead, you can just scan the service you touched and do it all in the poll request. Smaller units of work mean faster iteration and better security feedback. It's not perfect, but it's better than waiting three days for a big scan to finish full of false positives. Security teams also remember when a bad deploy meant logging into five servers and trying to figure out what went wrong. That's mostly gone now, right? Microservices introduced versioned deploys, rolling updates, canary releases, automated rollbacks. All of this makes reacting to incidents way faster. You can ship a fix or revert a change in minutes instead of hours, usually during an incident response call. On top of that, observability capabilities are a lot better now too. With logs, metrics and traces all getting distributed. Distributed tracing has gone from a fancy niche capability to being built in, and now security teams can actually follow the flow of data between services, catch anomalies, and prove impact faster when things go sideways. The runtime security capabilities have truly never been cooler. From supply chain scanning, to runtime threat detection, to better policy management, we now have more granular control than ever over our environments. Each service becomes its own layer of defense. Each CI job is a change to enforce policy. Each deployment is an opportunity to validate what's running and who's allowed to run it. Yes, it's more surface area, but it's also more visibility and more opportunities to do the right thing. If we're willing to adapt by making better policies, better code, and to build security as part of the developer experience, we can actually make things better than they were before. Microservices make security harder, but they also give us a chance to make it better.

Contents