Skip to content

Commit

Permalink
Merge pull request #23719 from ryancormack/main
Browse files Browse the repository at this point in the history
feat: Add App Config Feature Flag type
  • Loading branch information
ewbankkit authored Mar 17, 2022
2 parents 5d62e74 + 80533bb commit eadb7f4
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .changelog/23719.txt
Original file line number Diff line number Diff line change
@@ -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/)
```
14 changes: 12 additions & 2 deletions internal/service/appconfig/configuration_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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())
}
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions internal/service/appconfig/configuration_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
{
Expand Down
13 changes: 13 additions & 0 deletions internal/service/appconfig/enum.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package appconfig

const (
ConfigurationProfileTypeAWSAppConfigFeatureFlags = "AWS.AppConfig.FeatureFlags"
ConfigurationProfileTypeAWSFreeform = "AWS.Freeform"
)

func ConfigurationProfileType_Values() []string {
return []string{
ConfigurationProfileTypeAWSAppConfigFeatureFlags,
ConfigurationProfileTypeAWSFreeform,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
})
}
```
Expand Down

0 comments on commit eadb7f4

Please sign in to comment.