Feature flags are an important tool that enables trunk-based development. They allow in-progress features to be merged into the main branch while still allowing that branch to be deployed to production at any time, thus decoupling application deploys from feature releases. For a deeper introduction, Martin Fowler's article on Feature Toggles and LaunchDarkly's blog post on feature flags are both great articles that explain the what and why of feature flags.
This project leverages Amazon CloudWatch Evidently to create and manage feature flags.
The list of feature flags for an application is defined in the feature_flags
property in its app-config module (in /infra/[app_name]/app-config/feature-flags.tf
). To create a new feature flag, add a new string to that list. To remove a feature flag, remove the feature flag from the list. The set of feature flags will be updated on the next terraform apply
of the service layer, or during the next deploy of the application.
To determine whether a particular feature should be enabled or disabled for a given user, the application code calls an "is feature enabled" function in the feature flags module. Under the hood, the module will call AWS Evidently's EvaluateFeature API to determine whether a feature is enabled or disabled. For partial rollouts, it will remember which variation of the application a particular user saw and keep the user experience consistent for that user. For more information about the feature flags module, look in the application code and docs.
The system is designed to allow the managing of feature releases and partial rollouts outside of Terraform, which empowers business owners and product managers to control enable and disable feature flags and adjust feature launch traffic percentages without needing to depend on the development team.
- Navigate to the Evidently service in AWS Console, select the appropriate Evidently feature flags project for the relevant application environment, and select the feature you want to manage.
- In the actions menu, select "Edit feature".
- Under "Feature variations", select either "FeatureOn" (to enable a feature) or "FeatureOff" (to disable a feature) to be the "Default" variation, then submit. Warning: Do not modify the variation values. "FeatureOn" should always have a value of "True" and "FeatureOff" should always have a value of "False".
- Navigate to the Evidently service in AWS Console, and select the appropriate Evidently feature flags project for the relevant application environment
- Select "Create launch" to create a new partial rollout plan, or select an existing launch to manage an existing rollout
- Under "Launch configuration", choose the traffic percentage you want to send to each variation, and choose whether you want the launch to begin immediately or on a schedule.