Implementing Feature Flags with AWS AppConfig - Safe Configuration Deployment and Rollback

Roll out configuration changes independently from code deployments using Linear and Exponential strategies. Ensure safety with automatic rollback triggered by CloudWatch alarms.

Overview of AppConfig

AppConfig is a service for safely deploying application configuration. It allows you to change feature flags, tuning parameters, allow lists, and other settings independently from code deployments. Configuration changes are rolled out gradually and can be rolled back automatically by an alarm set as a monitor. Applications running on Lambda, ECS, or EC2 retrieve configuration via the SDK or extensions. Provided as a feature of Systems Manager, it has its own service endpoint and a dedicated AppConfig console. Configuration profiles come in two types: freeform (YAML/JSON/text) and feature flags (structured ON/OFF with variations), chosen based on the use case.

Deployment Strategies and Automatic Rollback

Deployment strategies control the speed of rollout. Linear deploys evenly at fixed intervals, while Exponential starts with a small number of hosts and gradually expands. AWS provides preset strategies such as AppConfig.Linear50PercentEvery30Seconds (fast deployment for testing) and AppConfig.AllAtOnce (immediate rollout). Custom strategies allow you to configure deployment time, growth factor, and final bake time. When you set a CloudWatch alarm as a monitor, automatic rollback is triggered if the alarm fires during deployment. For example, you can set an error rate alarm so that if errors increase with the new configuration, it reverts to the previous settings. Validators come in two types: JSON Schema for syntax checking and Lambda functions for logic checking, validating configuration values before deployment. Lambda validators can implement advanced validation including external API calls and database lookups.

Feature Flag Design Patterns

Feature flags are defined in JSON format, with each flag having an enabled/disabled state and attributes (target users, rollout percentage). In a gradual rollout, you first expose a new feature to 5% of internal users, then expand to 25%, 50%, and 100% while monitoring error rates. Lambda extensions cache flag values and reduce calls to retrieve configuration. You can set different flag values per environment (dev/staging/prod) and apply gradual rollout only in the production environment.

Comparison with Other Feature Flag Approaches

Besides AppConfig, feature flag implementations include environment variables, Parameter Store, SaaS solutions like LaunchDarkly, and custom database flag tables. Environment variables are simple but require deployment to change and lack gradual rollout. Systems Manager Parameter Store supports real-time retrieval but does not include built-in gradual deployment strategies or rollback mechanisms. SaaS solutions like LaunchDarkly offer user segmentation and targeting features but introduce external service dependency and monthly costs. AppConfig is an AWS service that handles gradual deployment and rollback by CloudWatch alarms in the same mechanism. On the other hand, when detailed targeting based on user attributes (A/B testing, etc.) is needed, external SaaS solutions are also an option.

Operational Best Practices and Pitfalls

In operations, establish a prefix naming convention (feature-name-flag-name) for flags so they remain searchable as numbers grow. Remove flags promptly when no longer needed to prevent remaining code references from becoming technical debt. Set the deployment strategy's bake time (FinalBakeTimeInMinutes) to at least as long as it takes for application metrics to stabilize; if too short, the deployment completes before errors surface and rollback cannot trigger. The Lambda extension polling interval defaults to 45 seconds but can be shortened when you want configuration changes to take effect sooner. However, shorter intervals increase request counts and affect costs, so balance traffic volume with responsiveness. Avoid packing many flags into a single profile, and split profiles per microservice.

AppConfig Pricing

AppConfig charges are based on usage such as configuration retrieval requests. Enabling caching with Lambda extensions consolidates requests to one per polling interval (default 45 seconds), keeping request counts low even with high Lambda invocation rates.

Summary

AppConfig is a service for safely deploying feature flags and configuration values independently from code deployments. It gradually rolls out changes using Linear and Exponential deployment strategies, and reduces incident risk from configuration changes through automatic rollback triggered by CloudWatch alarms. It can also cache and retrieve configuration through Lambda extensions. Gradual deployment runs within AWS services, and designing flag management and deployment strategies in advance makes features easier to release.

References (Official AWS Resources)

The primary sources for this page are the official AWS website and documentation. Check the official pages below for the latest specifications and pricing.

If this page and the official documentation disagree, treat the official documentation as authoritative.

Share