Search code examples
amazon-web-servicesterraformterraform-provider-awsaws-app-config

aws terraform, how to create feature flag instead of type freeform appconfig flag


Following is my appconfig code

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" # Replace with your SSM document ARN or another supported location
  description    = "AppConfig Configuration Profile for Lambda"
}

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"
  })
}

The corresponding flag created by terraform is of type freeform, not sure what I am missing.

I tried to create appconfig feature flag of type feature flag, I am getting a feature flag of type freeform


Solution

  • You need to fix the other resource, aws_appconfig_configuration_profile to set it to be of type AWS.AppConfig.FeatureFlags:

    resource "aws_appconfig_configuration_profile" "feature_flag_app" {
      name           = "FFConfigurationProfile"
      application_id = aws_appconfig_application.feature_flag_app.id
      location_uri   = "hosted" # Replace with your SSM document ARN or another supported location
      description    = "AppConfig Configuration Profile for Lambda"
      type           = "AWS.AppConfig.FeatureFlags"
    }
    

    Without the type argument it is by default AWS.Freeform:

    type - (Optional) Type of configurations contained in the profile. Valid values: AWS.AppConfig.FeatureFlags and AWS.Freeform. Default: AWS.Freeform.