Feature flags (also known as feature toggles) decouple feature releases from container deployments. In containerized environments on Amazon Elastic Container Service (Amazon ECS) and Amazon Elastic Kubernetes Service (Amazon EKS), the immutable nature of containers means changing behavior traditionally requires rebuilding and redeploying images. Feature flags address this by decoupling configuration changes from container restarts. Common approaches to dynamic configuration in containers each have limitations. Environment variables require task or pod restarts.

Mounting configuration from external stores adds complexity and requires custom polling logic. These approaches either force redeployments or push caching and synchronization complexity into your application code. AWS AppConfig, a capability of AWS Systems Manager, solves both problems with the sidecar pattern: the AWS AppConfig Agent runs alongside your application container, handling configuration retrieval, caching, and refresh automatically. Your application reads flags through a local HTTP call. It needs no SDK, no polling logic, and no credential management in your code.

In this post, you implement a discount promotion feature flag in ECS and EKS environments using this pattern. You set up AWS AppConfig, deploy the agent sidecar on both platforms, and toggle application behavior at runtime without redeploying containers.

Figure 1: The sidecar pattern, showing an Amazon EKS pod running an application container beside an AWS AppConfig Agent sidecar on the left and an Amazon ECS task with the same arrangement on the right, where both sidecars poll AWS AppConfig to provide local caching, retry logic, and graceful degradation The AWS AppConfig Agent deploys as a sidecar container in the same pod (EKS) or task (ECS) as your application. It creates a local HTTP endpoint on localhost:2772 that your application queries for configuration data.