Skip to content
v2.277.0

FeatureFlags Class ​

Features that are implemented behind a flag in order to preserve backwards compatibility for existing apps.

The list of flags are available in the aws-cdk-lib/cx-api module.

The state of the flag for this application is stored as a CDK context variable.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
const featureFlags = cdk.FeatureFlags.of(this);
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk

feature_flags = cdk.FeatureFlags.of(self)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;

FeatureFlags featureFlags = FeatureFlags.of(this);
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;

var featureFlags = FeatureFlags.Of(this);
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import cdk "github.com/aws/aws-cdk-go/awscdk"

featureFlags := cdk.FeatureFlags_Of(this)

Methods ​

isEnabled(featureFlag: string): booleandef is_enabled(self, feature_flag: str) -> boolpublic Boolean isEnabled(String featureFlag)public bool IsEnabled(string featureFlag)func IsEnabled(FeatureFlag *string) *bool#
Check whether a feature flag is enabled.

If configured, the flag is present in the construct node context. Falls back to the defaults defined in the cx-api module.

of(scope: IConstruct): FeatureFlags // chainable@staticmethod def of(scope: IConstruct) -> FeatureFlagspublic static FeatureFlags of(IConstruct scope)public static FeatureFlags Of(IConstruct scope)func Of(Scope IConstruct) FeatureFlagsstatic#
Inspect feature flags on the construct node's context.