创建功能标志配置文件(命令行) - Amazon AppConfig
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

创建功能标志配置文件(命令行)

以下过程介绍了如何使用 Amazon Command Line Interface(在 Linux 或 Windows 上)或 Tools for Windows PowerShell 创建 Amazon AppConfig 功能标志配置文件。在创建配置文件时,也可以创建基本功能标志。

创建功能标志配置
  1. 打开 Amazon CLI。

  2. 创建一个功能标志配置文件,将其类型指定为 AWS.AppConfig.FeatureFlags。配置文件必须使用 hosted 作为位置 URI。

    Linux
    aws appconfig create-configuration-profile \ --application-id APPLICATION_ID \ --name CONFIGURATION_PROFILE_NAME \ --location-uri hosted \ --type AWS.AppConfig.FeatureFlags
    Windows
    aws appconfig create-configuration-profile ^ --application-id APPLICATION_ID ^ --name CONFIGURATION_PROFILE_NAME ^ --location-uri hosted ^ --type AWS.AppConfig.FeatureFlags
    PowerShell
    New-APPCConfigurationProfile ` -Name CONFIGURATION_PROFILE_NAME ` -ApplicationId APPLICATION_ID ` -LocationUri hosted ` -Type AWS.AppConfig.FeatureFlags
  3. 创建功能标志配置数据。您的数据必须采用 JSON 格式,并符合 AWS.AppConfig.FeatureFlags JSON 架构。有关架构的更多信息,请参阅 了解 AWS.AppConfig.FeatureFlags 的类型引用

  4. 使用 CreateHostedConfigurationVersion API 将功能标志配置数据保存到 Amazon AppConfig。

    Linux
    aws appconfig create-hosted-configuration-version \ --application-id APPLICATION_ID \ --configuration-profile-id CONFIGURATION_PROFILE_ID \ --content-type "application/json" \ --content file://path/to/feature_flag_configuration_data.json \ --cli-binary-format raw-in-base64-out
    Windows
    aws appconfig create-hosted-configuration-version ^ --application-id APPLICATION_ID ^ --configuration-profile-id CONFIGURATION_PROFILE_ID ^ --content-type "application/json" ^ --content file://path/to/feature_flag_configuration_data.json ^ --cli-binary-format raw-in-base64-out
    PowerShell
    New-APPCHostedConfigurationVersion ` -ApplicationId APPLICATION_ID ` -ConfigurationProfileId CONFIGURATION_PROFILE_ID ` -ContentType "application/json" ` -Content file://path/to/feature_flag_configuration_data.json

    该命令从磁盘加载为 Content 参数指定的内容。内容必须类似于以下示例。

    { "flags": { "ui_refresh": { "name": "UI Refresh" } }, "values": { "ui_refresh": { "enabled": false, "attributeValues": { "dark_mode_support": true } } }, "version": "1" }

    系统将返回类似于以下内容的信息。

    Linux
    {
       "ApplicationId"          : "ui_refresh",
       "ConfigurationProfileId" : "UI Refresh",
       "VersionNumber"          : "1",
       "ContentType"            : "application/json"
    }
    Windows
    {
       "ApplicationId"          : "ui_refresh",
       "ConfigurationProfileId" : "UI Refresh",
       "VersionNumber"          : "1",
       "ContentType"            : "application/json"
    }
    PowerShell
    ApplicationId          : ui_refresh
    ConfigurationProfileId : UI Refresh
    VersionNumber          : 1
    ContentType            : application/json

    service_returned_content_file 包含您的配置数据,其中包括一些 Amazon AppConfig 生成的元数据。

    注意

    创建托管配置版本时,Amazon AppConfig 会验证您的数据是否符合 AWS.AppConfig.FeatureFlags JSON 架构。 此外,Amazon AppConfig 还会验证数据中的每个要素标志属性是否满足为这些属性定义的约束。