Use flag sets

Flag sets in App Lifecycle Manager let you group related feature flags by functional area or application component. Instead of managing flags individually in a flat list, you can create releases from sets and configure OpenFeature providers to subscribe to them.

Prerequisites

Before you begin, ensure you have:

  1. A gcloud environment configured to manage App Lifecycle Manager resources.
  2. Completed the Deploy feature flags quickstart or the Deploy with the gcloud CLI quickstart.

Group feature flags

To group flags, you associate them with a flag_set identifier during creation, or update an existing flag. This identifier creates a clear boundary of ownership and lets you use the flags set as a single resource.

Create a flag in a flag set

gcloud beta app-lifecycle-manager flags create "auth-flag" \
    --key="auth-flag" \
    --flag-value-type=bool \
    --location=global \
    --unit-kind="UNIT_KIND_NAME" \
    --flag-set="auth-module-flags" \
    --description="Flag for the core authentication service." \
    --with-default-evaluation

Update an existing flag to add to a flag set

gcloud beta app-lifecycle-manager flags update "auth-flag" \
    --location="global" \
    --flag-set="auth-module-flags"

Create a release from a flag set

Instead of manually creating point-in-time snapshots (FlagRevisions) for every flag, you can create a FlagRelease that references one or more sets. App Lifecycle Manager automatically handles the creation of all necessary immutable snapshots.

gcloud beta app-lifecycle-manager flags releases create "auth-release-v1.2" \
    --location=global \
    --flag-sets="auth-module-flags" \
    --unit-kind="UNIT_KIND_NAME"

Replace UNIT_KIND_NAME with your unit kind.

Create a release for all flags

You can set the all_flags boolean to true to fetch all flags linked to the rollout's unit kind:

gcloud beta app-lifecycle-manager flags releases create "all-flags-release" \
    --location=global \
    --all-flags \
    --unit-kind="UNIT_KIND_NAME"

Consuming a flag set

To subscribe to a flag set, use a selector when you initialize the OpenFeature provider.

Go example:

The selector tells the flag source to filter for this specific set:

provider := flagd.NewProvider(
    // The selector tells the flag source to filter for this specific set
    flagd.WithSelector("flagSetId=auth-module-flags"),
    // ... other options
)

Selector Behavior:

  • Empty selector: Selects only flags that have no flag set ID.
  • flagSetId=*: Selects all flags associated with the unit.
  • flagSetId=X: Selects only flags where the set is exactly X.

What's next