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

如何用Terraform创建AWS AppConfig功能标志而非自由格式标志

解决AWS AppConfig功能标志创建为自由格式的问题

你当前的Terraform代码未指定配置文件的类型,默认会生成自由格式配置文件。要创建功能标志类型的AWS AppConfig配置,需对aws_appconfig_configuration_profile资源做如下修改:

修改后的完整代码

resource "aws_appconfig_application" "feature_flag_app" {
  name        = "FFApplication"
  description = "AppConfig Application for Lambda"
}

resource "aws_appconfig_environment" "feature_flag_app" {
  name           = "FFEnvironment"
  application_id = aws_appconfig_application.feature_flag_app.id
  description    = "AppConfig Environment for Lambda"
}

resource "aws_appconfig_configuration_profile" "feature_flag_app" {
  name           = "FFConfigurationProfile"
  application_id = aws_appconfig_application.feature_flag_app.id
  location_uri   = "hosted"
  description    = "AppConfig Configuration Profile for Lambda"
  # 关键配置:指定配置文件类型为功能标志
  type           = "AWS.AppConfig.FeatureFlags"
}

resource "aws_appconfig_hosted_configuration_version" "feature_flag_app" {
  application_id           = aws_appconfig_application.feature_flag_app.id
  configuration_profile_id = aws_appconfig_configuration_profile.feature_flag_app.configuration_profile_id
  description              = "Example Feature Flag Configuration Version"
  content_type             = "application/json"

  content = jsonencode({
    flags : {
      simpleflag : {
        name : "simpleflag",
        _deprecation : {
          "status" : "planned"
        }
      }
    },
    values : {
      dbaccess : {
        enabled : "true",
      }
    },
    version : "1"
  })
}

核心修改说明

  • 添加type = "AWS.AppConfig.FeatureFlags":这是区分自由格式和功能标志类型的关键参数,AWS AppConfig会根据该值识别配置文件的类型,自动启用功能标志相关的管理界面和特性。
  • 你的配置内容结构已符合AWS AppConfig功能标志的JSON格式要求,无需额外调整。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.25 09:32:48