From 1236ea3b2233aa4c59520bb86d7659f79251c3fd Mon Sep 17 00:00:00 2001 From: Ryan Cormack Date: Wed, 16 Mar 2022 20:44:23 +0000 Subject: [PATCH 01/10] feat: Add App Config Feature Flag type Feature Flags are now GA on AWS. Extend the Configuration Profile to expose the ability to set these values. --- internal/service/appconfig/configuration_profile.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/service/appconfig/configuration_profile.go b/internal/service/appconfig/configuration_profile.go index 6ac3d0c3a5c..10d18225888 100644 --- a/internal/service/appconfig/configuration_profile.go +++ b/internal/service/appconfig/configuration_profile.go @@ -63,6 +63,12 @@ func ResourceConfigurationProfile() *schema.Resource { Optional: true, ValidateFunc: verify.ValidARN, }, + "type": { + Type: schema.TypeString, + Optional: true, + Default: "AWS.Freeform", + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^[a-zA-Z\.]+`), ""), + }, "tags": tftags.TagsSchema(), "tags_all": tftags.TagsSchemaComputed(), "validator": { @@ -121,6 +127,10 @@ func resourceConfigurationProfileCreate(d *schema.ResourceData, meta interface{} input.Validators = expandAppconfigValidators(v.(*schema.Set).List()) } + if v, ok := d.GetOk("type"); ok { + input.Type = aws.String(v.(string)) + } + profile, err := conn.CreateConfigurationProfile(input) if err != nil { From b6b11612ad793a662bde470b991229577798b545 Mon Sep 17 00:00:00 2001 From: Ryan Cormack Date: Wed, 16 Mar 2022 21:15:12 +0000 Subject: [PATCH 02/10] Add changelog and updated the docs --- .changelog/23719.txt | 3 +++ website/docs/r/appconfig_configuration_profile.html.markdown | 1 + 2 files changed, 4 insertions(+) create mode 100644 .changelog/23719.txt diff --git a/.changelog/23719.txt b/.changelog/23719.txt new file mode 100644 index 00000000000..407a89ee607 --- /dev/null +++ b/.changelog/23719.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_configuration_profile: Add `type` argument +``` \ No newline at end of file diff --git a/website/docs/r/appconfig_configuration_profile.html.markdown b/website/docs/r/appconfig_configuration_profile.html.markdown index 1a97b19541c..7f8e58292e1 100644 --- a/website/docs/r/appconfig_configuration_profile.html.markdown +++ b/website/docs/r/appconfig_configuration_profile.html.markdown @@ -41,6 +41,7 @@ The following arguments are supported: * `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. * `validator` - (Optional) A set of methods for validating the configuration. Maximum of 2. See [Validator](#validator) below for more details. +* `type` - (Optional) The type of the configuration profile. This will default to `AWS.Freeform`. ### Validator From d64df1243a88e7bf61258143487ffa26694c1b94 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Thu, 17 Mar 2022 08:28:35 -0400 Subject: [PATCH 03/10] Tweak CHANGELOG entry. --- .changelog/23719.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changelog/23719.txt b/.changelog/23719.txt index 407a89ee607..fab7addd3a5 100644 --- a/.changelog/23719.txt +++ b/.changelog/23719.txt @@ -1,3 +1,3 @@ ```release-note:enhancement -resource/aws_configuration_profile: Add `type` argument +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 From 94e0e42e794a8688001af44c72ada64e3a2a750f Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Thu, 17 Mar 2022 08:42:30 -0400 Subject: [PATCH 04/10] r/aws_appconfig_configuration_profile: Document valid values for 'type'. --- website/docs/r/appconfig_configuration_profile.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/appconfig_configuration_profile.html.markdown b/website/docs/r/appconfig_configuration_profile.html.markdown index 7f8e58292e1..4145f4d182a 100644 --- a/website/docs/r/appconfig_configuration_profile.html.markdown +++ b/website/docs/r/appconfig_configuration_profile.html.markdown @@ -40,8 +40,8 @@ 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. -* `type` - (Optional) The type of the configuration profile. This will default to `AWS.Freeform`. ### Validator From 67cb90a9c48d85d5de035a2cb7f20a0053f7caca Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Thu, 17 Mar 2022 08:42:50 -0400 Subject: [PATCH 05/10] r/aws_appconfig_configuration_profile: Test 'type' value. --- internal/service/appconfig/configuration_profile_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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"), ), }, { From 0261ef200ddbc5067e5d52be06874aae97228cbb Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Thu, 17 Mar 2022 08:43:54 -0400 Subject: [PATCH 06/10] r/aws_appconfig_configuration_profile: Add enumeration for type values; 'type' is ForceNew; read 'type' value. --- .../appconfig/configuration_profile.go | 20 +++++++++---------- internal/service/appconfig/enum.go | 13 ++++++++++++ 2 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 internal/service/appconfig/enum.go diff --git a/internal/service/appconfig/configuration_profile.go b/internal/service/appconfig/configuration_profile.go index 10d18225888..68e4c0ad95d 100644 --- a/internal/service/appconfig/configuration_profile.go +++ b/internal/service/appconfig/configuration_profile.go @@ -63,14 +63,15 @@ func ResourceConfigurationProfile() *schema.Resource { Optional: true, ValidateFunc: verify.ValidARN, }, + "tags": tftags.TagsSchema(), + "tags_all": tftags.TagsSchemaComputed(), "type": { Type: schema.TypeString, Optional: true, - Default: "AWS.Freeform", - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^[a-zA-Z\.]+`), ""), + ForceNew: true, + Default: ConfigurationProfileTypeAWSFreeform, + ValidateFunc: validation.StringInSlice(ConfigurationProfileType_Values(), false), }, - "tags": tftags.TagsSchema(), - "tags_all": tftags.TagsSchemaComputed(), "validator": { Type: schema.TypeSet, Optional: true, @@ -123,14 +124,14 @@ func resourceConfigurationProfileCreate(d *schema.ResourceData, meta interface{} input.RetrievalRoleArn = aws.String(v.(string)) } - if v, ok := d.GetOk("validator"); ok && v.(*schema.Set).Len() > 0 { - input.Validators = expandAppconfigValidators(v.(*schema.Set).List()) - } - 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()) + } + profile, err := conn.CreateConfigurationProfile(input) if err != nil { @@ -183,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) @@ -197,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/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, + } +} From d4244f2b608477e2c4fd638213f0ffc8824b7ccb Mon Sep 17 00:00:00 2001 From: Ryan Cormack Date: Thu, 17 Mar 2022 13:42:54 +0000 Subject: [PATCH 07/10] Extended documentation Show example differences for freeform and feature flags hosted configuration profile types --- ...hosted_configuration_version.html.markdown | 42 +++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/website/docs/r/appconfig_hosted_configuration_version.html.markdown b/website/docs/r/appconfig_hosted_configuration_version.html.markdown index ef90ce6ddfb..58001641493 100644 --- a/website/docs/r/appconfig_hosted_configuration_version.html.markdown +++ b/website/docs/r/appconfig_hosted_configuration_version.html.markdown @@ -10,21 +10,57 @@ description: |- Provides an AppConfig Hosted Configuration Version resource. -## Example Usage +## 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 Hosted Configuration Version" + description = "Example Freeform Hosted Configuration Version" content_type = "application/json" content = jsonencode({ - foo = "bar" + foo = "bar", + fruit = ["apple", "pear", "orange"], + isThingEnabled = true }) } ``` +## Example Usage Feature Flag + +```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({ + flags: { + foo: { + name: "foo", + _deprecation: { + "status": "planned" + } + } + bar: { + name: "bar", + } + } + values: { + foo: { + enabled: "true", + } + bar: { + enabled: "true", + } + } + version: "1" + }) +} +``` + ## Argument Reference The following arguments are supported: From 8a5cdda5c77455560c8b0a808bd486446fd7ca53 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Thu, 17 Mar 2022 12:12:59 -0400 Subject: [PATCH 08/10] Fix tfproviderdocs error 'error checking file contents: example section heading'. --- .../r/appconfig_hosted_configuration_version.html.markdown | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/website/docs/r/appconfig_hosted_configuration_version.html.markdown b/website/docs/r/appconfig_hosted_configuration_version.html.markdown index 58001641493..d9c91122be7 100644 --- a/website/docs/r/appconfig_hosted_configuration_version.html.markdown +++ b/website/docs/r/appconfig_hosted_configuration_version.html.markdown @@ -10,7 +10,9 @@ description: |- Provides an AppConfig Hosted Configuration Version resource. -## Example Usage Freeform +## Example Usage + +### Freeform ```terraform resource "aws_appconfig_hosted_configuration_version" "example" { @@ -27,7 +29,7 @@ resource "aws_appconfig_hosted_configuration_version" "example" { } ``` -## Example Usage Feature Flag +### Feature Flags ```terraform resource "aws_appconfig_hosted_configuration_version" "example" { From b09f04fd4277f5e9013883156e535da037735649 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Thu, 17 Mar 2022 12:17:53 -0400 Subject: [PATCH 09/10] Fix terrafmt errors in documentation. --- ...hosted_configuration_version.html.markdown | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/website/docs/r/appconfig_hosted_configuration_version.html.markdown b/website/docs/r/appconfig_hosted_configuration_version.html.markdown index d9c91122be7..3d48e13e5e0 100644 --- a/website/docs/r/appconfig_hosted_configuration_version.html.markdown +++ b/website/docs/r/appconfig_hosted_configuration_version.html.markdown @@ -39,27 +39,27 @@ resource "aws_appconfig_hosted_configuration_version" "example" { content_type = "application/json" content = jsonencode({ - flags: { - foo: { - name: "foo", - _deprecation: { - "status": "planned" - } - } - bar: { - name: "bar", + flags: { + foo: { + name: "foo", + _deprecation: { + "status": "planned" } } - values: { - foo: { - enabled: "true", - } - bar: { - enabled: "true", - } + bar: { + name: "bar", } - version: "1" - }) + } + values: { + foo: { + enabled: "true", + } + bar: { + enabled: "true", + } + } + version: "1" + }) } ``` From 80533bba0924568f4220493a100a9d34e41af66b Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Thu, 17 Mar 2022 12:24:35 -0400 Subject: [PATCH 10/10] Run 'terraform fmt' on the example configuration. --- ...hosted_configuration_version.html.markdown | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/website/docs/r/appconfig_hosted_configuration_version.html.markdown b/website/docs/r/appconfig_hosted_configuration_version.html.markdown index 3d48e13e5e0..952f6a254b8 100644 --- a/website/docs/r/appconfig_hosted_configuration_version.html.markdown +++ b/website/docs/r/appconfig_hosted_configuration_version.html.markdown @@ -39,26 +39,26 @@ resource "aws_appconfig_hosted_configuration_version" "example" { content_type = "application/json" content = jsonencode({ - flags: { - foo: { - name: "foo", - _deprecation: { - "status": "planned" + flags : { + foo : { + name : "foo", + _deprecation : { + "status" : "planned" } } - bar: { - name: "bar", + bar : { + name : "bar", } } - values: { - foo: { - enabled: "true", + values : { + foo : { + enabled : "true", } - bar: { - enabled: "true", + bar : { + enabled : "true", } } - version: "1" + version : "1" }) } ```