diff --git a/.changelog/23719.txt b/.changelog/23719.txt new file mode 100644 index 00000000000..fab7addd3a5 --- /dev/null +++ b/.changelog/23719.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_configuration_profile: Add `type` argument to support [AWS AppConfig Feature Flags](https://aws.amazon.com/blogs/mt/using-aws-appconfig-feature-flags/) +``` \ No newline at end of file diff --git a/internal/service/appconfig/configuration_profile.go b/internal/service/appconfig/configuration_profile.go index 6ac3d0c3a5c..68e4c0ad95d 100644 --- a/internal/service/appconfig/configuration_profile.go +++ b/internal/service/appconfig/configuration_profile.go @@ -65,6 +65,13 @@ func ResourceConfigurationProfile() *schema.Resource { }, "tags": tftags.TagsSchema(), "tags_all": tftags.TagsSchemaComputed(), + "type": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Default: ConfigurationProfileTypeAWSFreeform, + ValidateFunc: validation.StringInSlice(ConfigurationProfileType_Values(), false), + }, "validator": { Type: schema.TypeSet, Optional: true, @@ -117,6 +124,10 @@ func resourceConfigurationProfileCreate(d *schema.ResourceData, meta interface{} input.RetrievalRoleArn = aws.String(v.(string)) } + if v, ok := d.GetOk("type"); ok { + input.Type = aws.String(v.(string)) + } + if v, ok := d.GetOk("validator"); ok && v.(*schema.Set).Len() > 0 { input.Validators = expandAppconfigValidators(v.(*schema.Set).List()) } @@ -173,8 +184,8 @@ func resourceConfigurationProfileRead(d *schema.ResourceData, meta interface{}) d.Set("description", output.Description) d.Set("location_uri", output.LocationUri) d.Set("name", output.Name) - d.Set("retrieval_role_arn", output.RetrievalRoleArn) + d.Set("type", output.Type) if err := d.Set("validator", flattenValidators(output.Validators)); err != nil { return fmt.Errorf("error setting validator: %w", err) @@ -187,7 +198,6 @@ func resourceConfigurationProfileRead(d *schema.ResourceData, meta interface{}) Resource: fmt.Sprintf("application/%s/configurationprofile/%s", appID, confProfID), Service: "appconfig", }.String() - d.Set("arn", arn) tags, err := ListTags(conn, arn) diff --git a/internal/service/appconfig/configuration_profile_test.go b/internal/service/appconfig/configuration_profile_test.go index 2e625c2f997..47a17a48bdd 100644 --- a/internal/service/appconfig/configuration_profile_test.go +++ b/internal/service/appconfig/configuration_profile_test.go @@ -31,13 +31,14 @@ func TestAccAppConfigConfigurationProfile_basic(t *testing.T) { Config: testAccConfigurationProfileNameConfig(rName), Check: resource.ComposeTestCheckFunc( testAccCheckConfigurationProfileExists(resourceName), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "appconfig", regexp.MustCompile(`application/[a-z0-9]{4,7}/configurationprofile/[a-z0-9]{4,7}`)), resource.TestCheckResourceAttrPair(resourceName, "application_id", appResourceName, "id"), + acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "appconfig", regexp.MustCompile(`application/[a-z0-9]{4,7}/configurationprofile/[a-z0-9]{4,7}`)), resource.TestMatchResourceAttr(resourceName, "configuration_profile_id", regexp.MustCompile(`[a-z0-9]{4,7}`)), resource.TestCheckResourceAttr(resourceName, "location_uri", "hosted"), resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttr(resourceName, "validator.#", "0"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, "type", "AWS.Freeform"), + resource.TestCheckResourceAttr(resourceName, "validator.#", "0"), ), }, { diff --git a/internal/service/appconfig/enum.go b/internal/service/appconfig/enum.go new file mode 100644 index 00000000000..133739ca070 --- /dev/null +++ b/internal/service/appconfig/enum.go @@ -0,0 +1,13 @@ +package appconfig + +const ( + ConfigurationProfileTypeAWSAppConfigFeatureFlags = "AWS.AppConfig.FeatureFlags" + ConfigurationProfileTypeAWSFreeform = "AWS.Freeform" +) + +func ConfigurationProfileType_Values() []string { + return []string{ + ConfigurationProfileTypeAWSAppConfigFeatureFlags, + ConfigurationProfileTypeAWSFreeform, + } +} diff --git a/website/docs/r/appconfig_configuration_profile.html.markdown b/website/docs/r/appconfig_configuration_profile.html.markdown index 1a97b19541c..4145f4d182a 100644 --- a/website/docs/r/appconfig_configuration_profile.html.markdown +++ b/website/docs/r/appconfig_configuration_profile.html.markdown @@ -40,6 +40,7 @@ The following arguments are supported: * `description` - (Optional) The description of the configuration profile. Can be at most 1024 characters. * `retrieval_role_arn` - (Optional) The ARN of an IAM role with permission to access the configuration at the specified `location_uri`. A retrieval role ARN is not required for configurations stored in the AWS AppConfig `hosted` configuration store. It is required for all other sources that store your configuration. * `tags` - (Optional) A map of tags to assign to the resource. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. +* `type` - (Optional) The type of configurations contained in the profile. Valid values: `AWS.AppConfig.FeatureFlags` and `AWS.Freeform`. Default: `AWS.Freeform`. * `validator` - (Optional) A set of methods for validating the configuration. Maximum of 2. See [Validator](#validator) below for more details. ### Validator diff --git a/website/docs/r/appconfig_hosted_configuration_version.html.markdown b/website/docs/r/appconfig_hosted_configuration_version.html.markdown index ef90ce6ddfb..952f6a254b8 100644 --- a/website/docs/r/appconfig_hosted_configuration_version.html.markdown +++ b/website/docs/r/appconfig_hosted_configuration_version.html.markdown @@ -12,15 +12,53 @@ Provides an AppConfig Hosted Configuration Version resource. ## Example Usage +### Freeform + +```terraform +resource "aws_appconfig_hosted_configuration_version" "example" { + application_id = aws_appconfig_application.example.id + configuration_profile_id = aws_appconfig_configuration_profile.example.configuration_profile_id + description = "Example Freeform Hosted Configuration Version" + content_type = "application/json" + + content = jsonencode({ + foo = "bar", + fruit = ["apple", "pear", "orange"], + isThingEnabled = true + }) +} +``` + +### Feature Flags + ```terraform resource "aws_appconfig_hosted_configuration_version" "example" { application_id = aws_appconfig_application.example.id configuration_profile_id = aws_appconfig_configuration_profile.example.configuration_profile_id - description = "Example Hosted Configuration Version" + description = "Example Freeform Hosted Configuration Version" content_type = "application/json" content = jsonencode({ - foo = "bar" + flags : { + foo : { + name : "foo", + _deprecation : { + "status" : "planned" + } + } + bar : { + name : "bar", + } + } + values : { + foo : { + enabled : "true", + } + bar : { + enabled : "true", + } + } + version : "1" }) } ```