Creating a feature flag configuration profile in Amazon AppConfig - Amazon AppConfig
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Creating a feature flag configuration profile in Amazon AppConfig

You can use feature flags to enable or disable features within your applications or to configure different characteristics of your application features using flag attributes. Amazon AppConfig stores feature flag configurations in the Amazon AppConfig hosted configuration store in a feature flag format that contains data and metadata about your flags and the flag attributes. For more information about the Amazon AppConfig hosted configuration store, see About the Amazon AppConfig hosted configuration store section.

Creating a feature flag and a feature flag configuration profile (console)

Use the following procedure to create an Amazon AppConfig feature flag configuration profile and a feature flag configuration by using the Amazon AppConfig console.

To create a configuration profile
  1. Open the Amazon Systems Manager console at https://console.amazonaws.cn/systems-manager/appconfig/.

  2. On the Applications tab, choose the application you created in Create an Amazon AppConfig configuration and then choose the Configuration profiles and feature flags tab.

  3. Choose Create.

  4. Choose Feature flag.

To create a feature flag
  1. On the configuration you created, choose Add new flag.

  2. Provide a Flag name and (optional) Description. The Flag key auto populates by replacing spaces with underscores in the name you provided. You can edit the flag key if you want a different value or format. After the flag is created, you can edit the flag name, but not the flag key.

  3. Specify whether the feature flag is Enabled or Disabled using the toggle button.

  4. (Optional) Add Attributes and attribute Constraints to the feature flag. Attributes enable you to provide additional values within your flag. You can optionally validate attribute values against specified constraints. Constraints ensure that any unexpected values are not deployed to your application.

    Amazon AppConfig feature flags supports the following types of attributes and their corresponding constraints.

    Type Constraint Description
    String Regular Expression

    Regex pattern for the string

    Enum

    List of acceptable values for the string

    Number Minimum

    Minimum numeric value for the attribute

    Maximum

    Maximum numeric value for the attribute

    Boolean None None
    String array Regular Expression Regex pattern for the elements of the array
    Enum List of acceptable values for the elements of the array
    Number array Minimum Minimum numeric value for the elements of the array
    Maximum Maximum numeric value for the elements of the array
    Note

    Note the following information.

    • For attribute names, the word "enabled" is reserved. You can't create a feature flag attribute called "enabled". There are no other reserved words.

    • The attributes of a feature flag are only included in the GetLatestConfiguration response if that flag is enabled.

    • Select Required value to specify whether an attribute value is required.

  5. Choose Save new version.

Proceed to Deploying feature flags and configuration data in Amazon AppConfig.

Creating a feature flag and a feature flag configuration profile (command line)

The following procedure describes how to use the Amazon Command Line Interface (on Linux or Windows) or Tools for Windows PowerShell to create an Amazon AppConfig feature flag configuration profile. If you prefer, you can use Amazon CloudShell to run the commands listed below. For more information, see What is Amazon CloudShell? in the Amazon CloudShell User Guide.

To create a feature flags configuration step by step
  1. Open the Amazon CLI.

  2. Create a feature flag configuration profile specifying its Type as AWS.AppConfig.FeatureFlags. The configuration profile must use hosted for the location URI.

    Linux
    aws appconfig create-configuration-profile \ --application-id The_application_ID \ --name A_name_for_the_configuration_profile \ --location-uri hosted \ --type AWS.AppConfig.FeatureFlags
    Windows
    aws appconfig create-configuration-profile ^ --application-id The_application_ID ^ --name A_name_for_the_configuration_profile ^ --location-uri hosted ^ --type AWS.AppConfig.FeatureFlags
    PowerShell
    New-APPCConfigurationProfile ` -Name A_name_for_the_configuration_profile ` -ApplicationId The_application_ID ` -LocationUri hosted ` -Type AWS.AppConfig.FeatureFlags
  3. Create your feature flag configuration data. Your data must be in a JSON format and conform to the AWS.AppConfig.FeatureFlags JSON schema. For more information about the schema, see Type reference for AWS.AppConfig.FeatureFlags.

  4. Use the CreateHostedConfigurationVersion API to save your feature flag configuration data to Amazon AppConfig.

    Linux
    aws appconfig create-hosted-configuration-version \ --application-id The_application_ID \ --configuration-profile-id The_configuration_profile_id \ --content-type "application/json" \ --content file://path/to/feature_flag_configuration_data \ file_name_for_system_to_store_configuration_data
    Windows
    aws appconfig create-hosted-configuration-version ^ --application-id The_application_ID ^ --configuration-profile-id The_configuration_profile_id ^ --content-type "application/json" ^ --content file://path/to/feature_flag_configuration_data ^ file_name_for_system_to_store_configuration_data
    PowerShell
    New-APPCHostedConfigurationVersion ` -ApplicationId The_application_ID ` -ConfigurationProfileId The_configuration_profile_id ` -ContentType "application/json" ` -Content file://path/to/feature_flag_configuration_data ` file_name_for_system_to_store_configuration_data

    Here's a Linux sample command.

    aws appconfig create-hosted-configuration-version \ --application-id 1a2b3cTestApp \ --configuration-profile-id 4d5e6fTestConfigProfile \ --content-type "application/json" \ --content Base64Content

    The content parameter uses the following base64 encoded data.

    { "flags": { "flagkey": { "name": "WinterSpecialBanner" } }, "values": { "flagkey": { "enabled": true } }, "version": "1" }

    The system returns information like the following.

    Linux
    {
       "ApplicationId"          : "1a2b3cTestApp",
       "ConfigurationProfileId" : "4d5e6fTestConfigProfile",
       "VersionNumber"          : "1",
       "ContentType"            : "application/json"
    }
    Windows
    {
       "ApplicationId"          : "1a2b3cTestApp",
       "ConfigurationProfileId" : "4d5e6fTestConfigProfile",
       "VersionNumber"          : "1",
       "ContentType"            : "application/json"
    }
    PowerShell
    ApplicationId          : 1a2b3cTestApp
    ConfigurationProfileId : 4d5e6fTestConfigProfile
    VersionNumber          : 1
    ContentType            : application/json

    The service_returned_content_file contains your configuration data that includes some Amazon AppConfig generated metadata.

    Note

    When you create the hosted configuration version, Amazon AppConfig verifies that your data conforms to the AWS.AppConfig.FeatureFlags JSON schema. Amazon AppConfig additionally validates that each feature flag attribute in your data satisfies the constraints you defined for those attributes.

Type reference for AWS.AppConfig.FeatureFlags

Use the AWS.AppConfig.FeatureFlags JSON schema as a reference to create your feature flag configuration data.

{ "$schema": "http://json-schema.org/draft-07/schema#", "definitions": { "flagSetDefinition": { "type": "object", "properties": { "version": { "$ref": "#/definitions/flagSchemaVersions" }, "flags": { "$ref": "#/definitions/flagDefinitions" }, "values": { "$ref": "#/definitions/flagValues" } }, "required": ["version", "flags"], "additionalProperties": false }, "flagDefinitions": { "type": "object", "patternProperties": { "^[a-z][a-zA-Z\\d-]{0,63}$": { "$ref": "#/definitions/flagDefinition" } }, "maxProperties": 100, "additionalProperties": false }, "flagDefinition": { "type": "object", "properties": { "name": { "$ref": "#/definitions/customerDefinedName" }, "description": { "$ref": "#/definitions/customerDefinedDescription" }, "_createdAt": { "type": "string" }, "_updatedAt": { "type": "string" }, "_deprecation": { "type": "object", "properties": { "status": { "type": "string", "enum": ["planned"] } }, "additionalProperties": false }, "attributes": { "$ref": "#/definitions/attributeDefinitions" } }, "additionalProperties": false }, "attributeDefinitions": { "type": "object", "patternProperties": { "^[a-z][a-zA-Z\\d-_]{0,63}$": { "$ref": "#/definitions/attributeDefinition" } }, "maxProperties": 25, "additionalProperties": false }, "attributeDefinition": { "type": "object", "properties": { "description": { "$ref": "#/definitions/customerDefinedDescription" }, "constraints": { "oneOf": [ { "$ref": "#/definitions/numberConstraints" }, { "$ref": "#/definitions/stringConstraints" }, { "$ref": "#/definitions/arrayConstraints" }, { "$ref": "#/definitions/boolConstraints" } ] } }, "additionalProperties": false }, "flagValues": { "type": "object", "patternProperties": { "^[a-z][a-zA-Z\\d-_]{0,63}$": { "$ref": "#/definitions/flagValue" } }, "maxProperties": 100, "additionalProperties": false }, "flagValue": { "type": "object", "properties": { "enabled": { "type": "boolean" }, "_createdAt": { "type": "string" }, "_updatedAt": { "type": "string" } }, "patternProperties": { "^[a-z][a-zA-Z\\d-_]{0,63}$": { "$ref": "#/definitions/attributeValue", "maxProperties": 25 } }, "required": ["enabled"], "additionalProperties": false }, "attributeValue": { "oneOf": [ { "type": "string", "maxLength": 1024 }, { "type": "number" }, { "type": "boolean" }, { "type": "array", "oneOf": [ { "items": { "type": "string", "maxLength": 1024 } }, { "items": { "type": "number" } } ] } ], "additionalProperties": false }, "stringConstraints": { "type": "object", "properties": { "type": { "type": "string", "enum": ["string"] }, "required": { "type": "boolean" }, "pattern": { "type": "string", "maxLength": 1024 }, "enum": { "type": "array", "maxLength": 100, "items": { "oneOf": [ { "type": "string", "maxLength": 1024 }, { "type": "integer" } ] } } }, "required": ["type"], "not": { "required": ["pattern", "enum"] }, "additionalProperties": false }, "numberConstraints": { "type": "object", "properties": { "type": { "type": "string", "enum": ["number"] }, "required": { "type": "boolean" }, "minimum": { "type": "integer" }, "maximum": { "type": "integer" } }, "required": ["type"], "additionalProperties": false }, "arrayConstraints": { "type": "object", "properties": { "type": { "type": "string", "enum": ["array"] }, "required": { "type": "boolean" }, "elements": { "$ref": "#/definitions/elementConstraints" } }, "required": ["type"], "additionalProperties": false }, "boolConstraints": { "type": "object", "properties": { "type": { "type": "string", "enum": ["boolean"] }, "required": { "type": "boolean" } }, "required": ["type"], "additionalProperties": false }, "elementConstraints": { "oneOf": [ { "$ref": "#/definitions/numberConstraints" }, { "$ref": "#/definitions/stringConstraints" } ] }, "customerDefinedName": { "type": "string", "pattern": "^[^\\n]{1,64}$" }, "customerDefinedDescription": { "type": "string", "maxLength": 1024 }, "flagSchemaVersions": { "type": "string", "enum": ["1"] } }, "type": "object", "$ref": "#/definitions/flagSetDefinition", "additionalProperties": false }
Important

To retrieve feature flag configuration data, your application must call the GetLatestConfiguration API. You can't retrieve feature flag configuration data by calling GetConfiguration, which is deprecated. For more information, see GetLatestConfiguration in the Amazon AppConfig API Reference.

When your application calls GetLatestConfiguration and receives a newly deployed configuration, the information that defines your feature flags and attributes is removed. The simplified JSON contains a map of keys that match each of the flag keys you specified. The simplified JSON also contains mapped values of true or false for the enabled attribute. If a flag sets enabled to true, any attributes of the flag will be present as well. The following JSON schema describes the format of the JSON output.

{ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "patternProperties": { "^[a-z][a-zA-Z\\d-_]{0,63}$": { "$ref": "#/definitions/attributeValuesMap" } }, "maxProperties": 100, "additionalProperties": false, "definitions": { "attributeValuesMap": { "type": "object", "properties": { "enabled": { "type": "boolean" } }, "required": ["enabled"], "patternProperties": { "^[a-z][a-zA-Z\\d-_]{0,63}$": { "$ref": "#/definitions/attributeValue" } }, "maxProperties": 25, "additionalProperties": false }, "attributeValue": { "oneOf": [ { "type": "string","maxLength": 1024 }, { "type": "number" }, { "type": "boolean" }, { "type": "array", "oneOf": [ { "items": { "oneOf": [ { "type": "string", "maxLength": 1024 } ] } }, { "items": { "oneOf": [ { "type": "number" } ] } } ] } ], "additionalProperties": false } } }