liveBook · Manning

Feature flag

As explained in Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform

A feature flag is a Boolean-controlled configuration mechanism that enables or disables a feature, resource, dependency, or attribute.

A feature flag is a Boolean configuration mechanism that enables or disables infrastructure resources, dependencies, or attributes. It stages changes while preserving the existing infrastructure state. section 10.1.2

Apply a feature flag through a short lifecycle:

  • Define the flag in one visible location, such as a dedicated configuration file or configuration manager. section 10.1.2 section 10.3
  • Default it to False so the original resources and dependencies remain unchanged. section 10.1.2
  • Reference the flag in infrastructure configuration to select the existing or replacement resources. section 10.1.2
  • Set it to True when the staged change is ready, then remove the flag after the change completes. section 10.1.2 section 10.3

Staging servers behind a load balancer

With ENABLE_SERVER_MODULE set to False, the load balancer keeps the original servers. Setting it to True attaches three module-created servers and detaches the old servers; the completed configuration removes the conditional flag. section 10.1.2

How Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform covers it

How deep it goes
Demonstrates definition, defaulting, conditional references, activation, and removal, but does not detail configuration-manager implementation.
Examples
Uses Python, JSON, Terraform, and CloudFormation examples to switch server modules and load-balancer membership.
What it assumes
Assumes familiarity with infrastructure as code, resources, dependencies, and conditional configuration.
What you can do after
Apply it via infrastructure as code to stage changes and limit their immediate impact on existing resources.
How it connects
Connects feature flags with infrastructure as code, refactoring, rolling updates, trunk-based development, and blue-green deployment.

Also explained in

Compare how 8 books explain feature flag →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform. The section links point to the parts of the book it draws on.