You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为AWS AppConfig功能标志添加带数值约束的percentEnabled属性?

为AWS AppConfig功能标志添加数值属性的CloudFormation实现

需求:

  • 已通过CloudFormation创建AWS AppConfig的ConfigurationProfile与HostedConfigurationVersion(类型为AWS.AppConfig.FeatureFlags),现有isFooFlagEnabled功能标志
  • 需为该标志添加名为percentEnabled的属性,要求:
    1. 数值类型
    2. 取值范围0-100之间

以下是实现该需求的CloudFormation代码:

"AppConfigProfileId": {
  "Type": "AWS::AppConfig::ConfigurationProfile",
  "Properties": {
    "ApplicationId": {
      "Ref": "AppConfig"
    },
    "Description": "Foo服务所有功能标志的顶级容器",
    "Name": "FeatureFlags",
    "LocationUri": "hosted",
    "Type": "AWS.AppConfig.FeatureFlags"
  }
},

"AppConfigFeatureFlagVersion": {
  "Type": "AWS::AppConfig::HostedConfigurationVersion",
  "Properties": {
    "ApplicationId": {
      "Ref": "AppConfig"
    },
    "ConfigurationProfileId": {
      "Ref": "AppConfigProfileId"
    },
    "Content": {
      "Fn::Join": [
        "\n",
        [
            "{",
            "    \"flags\": {",
            "        \"isFooFlagEnabled\": {",
            "            \"name\": \"isFooFlagEnabled\",",
            "            \"schema\": {",
            "                \"type\": \"object\",",
            "                \"properties\": {",
            "                    \"percentEnabled\": {",
            "                        \"type\": \"number\",",
            "                        \"minimum\": 0,",
            "                        \"maximum\": 100",
            "                    }
                },",
                "                \"required\": [\"percentEnabled\"]",
            "            }
            "        },",
            "    },",
            "    \"values\": {",
            "        \"isFooFlagEnabled\": {",
            "            \"enabled\": false,",
            "            \"percentEnabled\": 0",
            "        }
            "    },",
            "    \"version\": \"1\"",
            "}"
        ]
      ]
    },
    "ContentType": "application/json",
    "Description": "Foo标志的托管配置版本"
  }
}

实现说明:

  • 在flags下的isFooFlagEnabled节点中添加schema定义,明确percentEnabled为数值类型,同时通过minimum和maximum约束取值范围在0到100之间
  • 在values节点中为isFooFlagEnabled设置percentEnabled的初始值,这里设为0

内容的提问来源于stack exchange,提问作者user2185573

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 14:27:02