Overview

10 Benefits of cloud thinking

This chapter argues that “cloud thinking” — designing software with twelve-factor and cloud‑native principles — yields clear security gains whether you run on public cloud, a PaaS, or on‑premises. By favoring statelessness, environment‑agnostic deployment, and platform‑provided capabilities, teams can simplify nonfunctional concerns and systematically improve confidentiality, integrity, and availability. The focus is on design choices that inherently strengthen security rather than on platform hardening or vendor comparisons.

Key practices include externalizing configuration so code and secrets are never bundled together, avoiding credentials in code or resource files, and leveraging the environment (and IAM) to control access and auditing. Because environment variables can be read on many systems, the chapter advocates short‑lived, automatically rotated secrets over static, encrypted blobs. Running applications as separate, stateless processes with least privilege, and relying on backing services, improves containment, enables zero‑downtime rollout, and lets compromised instances be killed and replaced quickly. Centralized, service‑based logging strengthens confidentiality (fine‑grained access control and auditing), integrity (append‑only, separated write vs read paths, aggregated views), and availability (elastic storage and resilience), while avoiding the pitfalls of local log files. Treating admin functionality as a first‑class, version‑controlled, separately deployed interface reduces the attack surface compared to ad hoc SSH or direct database access and keeps operational tools in sync with the system. Finally, dynamic service discovery and load balancing embrace constant change, raising availability and making exploitation of a moving target harder.

These foundations enable the three R’s of enterprise security: rotate, repave, and repair. Rotate secrets frequently and prefer ephemeral credentials injected by the platform or retrieved from a dedicated service, minimizing the window of misuse. Repave servers, containers, and applications from known‑good images on a regular cadence via rolling deployments, erasing any footholds and keeping instances fresh without downtime. Repair quickly by rebuilding and redeploying as soon as patches are available—for operating systems, dependencies, and your own code—so an attacker can’t rely on a long‑lived, vulnerable target. While easiest on modern cloud platforms, the same approach can be achieved with virtual machines and containers on‑premises, and legacy systems can evolve toward these practices iteratively.

Figure 10.1. Configuration data provided by the environment.
ch10 config data provided by env small
Figure 10.2. Processes serving stateless requests, only communicating via backing services.
ch10 processes small
Figure 10.3. Every log call is sent over the network to the logging service.
ch10 logging over network small
Figure 10.4. Administrative tasks deployed to the server, ready to run via a separate API.
ch10 admin small
Figure 10.5. Centralized load balancing
ch10 centralized load balancing small
Figure 10.6. Client-side load balancing using service discovery
ch10 client side load balancing small
Figure 10.7. The platform injecting ephemeral secrets into the environment.
ch10 platform injected secrets small
Figure 10.8. The client retrieves secrets from a dedicated service.
ch10 app retrieved secrets small
Figure 10.9. Repaving instances by rolling deployment
ch10 rolling deployment small

 Summary

  • The twelve-factor app and cloud-native concepts can be used to increase the security of applications and systems.
  • You should run your application as stateless processes that can be started or decommissioned for any occasion.
  • Any result of processing should be stored to a backing service such as a database, log service, or distributed cache.
  • Separating code and configuration is the key to allowing deployment to multiple environments without rebuilding the application.
  • Sensitive data should never be stored in resource files because it can be accessed even after the application has terminated.
  • Configuration that changes with the environment should be part of the environment.
  • Administration tasks are important and should be part of the solution; these should be run as processes on the node.
  • Logging shouldn’t be done to a local file on disk because it yields several security issues.
  • Using a centralized logging service yields several security benefits, regardless of whether you’re running an application in the cloud or on-premise.
  • Service discovery can increase security by improving availability and promoting an ever-changing system.
  • Applying the concept of the three R’s—rotate, repave, and repair—significantly improves many aspects of security. Designing your applications for the cloud is a prerequisite for doing this.

FAQ

What is “cloud thinking,” and why does it improve security even outside the cloud?Cloud thinking means designing applications to be cloud-native: stateless, horizontally scalable, environment-agnostic, and managed by a platform (PaaS). These properties reduce complexity in the app, enable least-privilege operation, make replacing or scaling instances trivial, and allow rapid, automated change. Together they improve confidentiality, integrity, and availability and enable practices like rotating secrets, repaving instances, and repairing quickly.
How does externalizing configuration improve security?Separating code from configuration lets environments supply values (DNS, ports, credentials) at runtime. Security benefits include: - Reduced secret exposure in code repositories and images - Easier auditing by shifting access control to IAM on the environment/platform - Support for rotation and ephemeral secrets without rebuilds - Environment parity with fewer ad hoc tweaks that cause leaks
Why shouldn’t I store secrets in source code or resource files?Because it increases risk and reduces control: - Anyone with repo access can read secrets; there’s no audit trail - Secrets on disk can be exfiltrated outside the app process - Encrypting config files adds key management complexity (“chicken-and-egg”) - Secrets spread to all developers and vendors, complicating future sharing or open sourcing Use platform- or service-delivered secrets instead.
Are environment variables safe for secrets?They are better than embedding in code or files but not perfect: many OSs allow reading a process’s environment (for example via /proc). Prefer: - Platform-injected, short-lived (ephemeral) secrets that live only in RAM - Dedicated secret services the app calls to fetch rotating credentials - Strong IAM and auditing on who can set/read env values - Encrypt-in-transit when fetching secrets; avoid persisting them
What does “run as separate, stateless processes” mean, and how does it help security?Build/release/run are separated; runtime processes: - Hold no client state between requests - Communicate via backing services (DB, cache, queues) - Run with least privilege needed to serve requests Benefits: easier scaling and zero-downtime deploys (availability), simple kill-and-replace of suspect instances (integrity), and reduced blast radius if compromised.
Why avoid logging to local files, and what is “logging as a service”?Logging to disk harms: - Confidentiality: easy to copy, hard to audit fine-grained access - Integrity: tampering is difficult to prevent or prove - Availability: disks fill up; rotated files get lost; instances are ephemeral Logging as a service centralizes logs in a backing service over the network (use TLS), with append-only writes from trusted producers, role-based reads (separate Audit/System/Error), built-in audit trails, and aggregation across instances.
How should I structure admin functionality to be secure and reliable?Treat admin as first-class: - Version-control and deploy it with the system - Expose as a separate API/GUI and run as a separate process/container (and network if needed) - Avoid general-purpose SSH/SQL console access Benefits: - Confidentiality: minimal, purpose-built surface (no generic shells) - Integrity: admin tools stay in sync with app schemas/contracts - Availability: admin remains responsive under load
What are service discovery and load balancing, and how do they improve security?Load balancing spreads requests across instances; service discovery lets clients find healthy instances dynamically. Approaches: - Centralized LB (platform manages targets) - Client-side LB (caller discovers instances and chooses) Security impact: - Higher availability via elastic scaling and failure isolation - Constantly changing instance sets make exploitation and persistence harder
What are the Three R’s of enterprise security (Rotate, Repave, Repair)?- Rotate: Change secrets (passwords, tokens, certs) every minutes/hours; inject or fetch ephemeral values automatically. - Repave: Rebuild and redeploy servers/containers from known-good images regularly (rolling deployments), never reusing compromised state. - Repair: Apply OS/app/dependency patches fast by producing new images and repaving. Core idea: increase change to reduce attacker dwell time and disrupt advanced persistent threats.
How can I get started adopting these practices with existing systems?- Move configuration out of code into the environment/secret store - Centralize logging; stop writing logs to local disk - Run stateless processes; use backing services for state - Enforce least privilege and separate build/release/run - Introduce service discovery and automated load balancing - Ship versioned admin APIs as separate processes - Containerize and automate rolling deploys - Pilot Rotate/Repave/Repair on a non-critical service, then expand incrementally

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Secure by Design ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Secure by Design ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Secure by Design ebook for free