Skip to content

Commit eadb7f4

Browse files
authored
Merge pull request #23719 from ryancormack/main
feat: Add App Config Feature Flag type
2 parents 5d62e74 + 80533bb commit eadb7f4

6 files changed

+72
-6
lines changed

.changelog/23719.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/aws_configuration_profile: Add `type` argument to support [AWS AppConfig Feature Flags](https://aws.amazon.com/blogs/mt/using-aws-appconfig-feature-flags/)
3+
```

internal/service/appconfig/configuration_profile.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ func ResourceConfigurationProfile() *schema.Resource {
6565
},
6666
"tags": tftags.TagsSchema(),
6767
"tags_all": tftags.TagsSchemaComputed(),
68+
"type": {
69+
Type: schema.TypeString,
70+
Optional: true,
71+
ForceNew: true,
72+
Default: ConfigurationProfileTypeAWSFreeform,
73+
ValidateFunc: validation.StringInSlice(ConfigurationProfileType_Values(), false),
74+
},
6875
"validator": {
6976
Type: schema.TypeSet,
7077
Optional: true,
@@ -117,6 +124,10 @@ func resourceConfigurationProfileCreate(d *schema.ResourceData, meta interface{}
117124
input.RetrievalRoleArn = aws.String(v.(string))
118125
}
119126

127+
if v, ok := d.GetOk("type"); ok {
128+
input.Type = aws.String(v.(string))
129+
}
130+
120131
if v, ok := d.GetOk("validator"); ok && v.(*schema.Set).Len() > 0 {
121132
input.Validators = expandAppconfigValidators(v.(*schema.Set).List())
122133
}
@@ -173,8 +184,8 @@ func resourceConfigurationProfileRead(d *schema.ResourceData, meta interface{})
173184
d.Set("description", output.Description)
174185
d.Set("location_uri", output.LocationUri)
175186
d.Set("name", output.Name)
176-
177187
d.Set("retrieval_role_arn", output.RetrievalRoleArn)
188+
d.Set("type", output.Type)
178189

179190
if err := d.Set("validator", flattenValidators(output.Validators)); err != nil {
180191
return fmt.Errorf("error setting validator: %w", err)
@@ -187,7 +198,6 @@ func resourceConfigurationProfileRead(d *schema.ResourceData, meta interface{})
187198
Resource: fmt.Sprintf("application/%s/configurationprofile/%s", appID, confProfID),
188199
Service: "appconfig",
189200
}.String()
190-
191201
d.Set("arn", arn)
192202

193203
tags, err := ListTags(conn, arn)

internal/service/appconfig/configuration_profile_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ func TestAccAppConfigConfigurationProfile_basic(t *testing.T) {
3131
Config: testAccConfigurationProfileNameConfig(rName),
3232
Check: resource.ComposeTestCheckFunc(
3333
testAccCheckConfigurationProfileExists(resourceName),
34-
acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "appconfig", regexp.MustCompile(`application/[a-z0-9]{4,7}/configurationprofile/[a-z0-9]{4,7}`)),
3534
resource.TestCheckResourceAttrPair(resourceName, "application_id", appResourceName, "id"),
35+
acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "appconfig", regexp.MustCompile(`application/[a-z0-9]{4,7}/configurationprofile/[a-z0-9]{4,7}`)),
3636
resource.TestMatchResourceAttr(resourceName, "configuration_profile_id", regexp.MustCompile(`[a-z0-9]{4,7}`)),
3737
resource.TestCheckResourceAttr(resourceName, "location_uri", "hosted"),
3838
resource.TestCheckResourceAttr(resourceName, "name", rName),
39-
resource.TestCheckResourceAttr(resourceName, "validator.#", "0"),
4039
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
40+
resource.TestCheckResourceAttr(resourceName, "type", "AWS.Freeform"),
41+
resource.TestCheckResourceAttr(resourceName, "validator.#", "0"),
4142
),
4243
},
4344
{

internal/service/appconfig/enum.go

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package appconfig
2+
3+
const (
4+
ConfigurationProfileTypeAWSAppConfigFeatureFlags = "AWS.AppConfig.FeatureFlags"
5+
ConfigurationProfileTypeAWSFreeform = "AWS.Freeform"
6+
)
7+
8+
func ConfigurationProfileType_Values() []string {
9+
return []string{
10+
ConfigurationProfileTypeAWSAppConfigFeatureFlags,
11+
ConfigurationProfileTypeAWSFreeform,
12+
}
13+
}

website/docs/r/appconfig_configuration_profile.html.markdown

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ The following arguments are supported:
4040
* `description` - (Optional) The description of the configuration profile. Can be at most 1024 characters.
4141
* `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.
4242
* `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.
43+
* `type` - (Optional) The type of configurations contained in the profile. Valid values: `AWS.AppConfig.FeatureFlags` and `AWS.Freeform`. Default: `AWS.Freeform`.
4344
* `validator` - (Optional) A set of methods for validating the configuration. Maximum of 2. See [Validator](#validator) below for more details.
4445

4546
### Validator

website/docs/r/appconfig_hosted_configuration_version.html.markdown

+40-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,53 @@ Provides an AppConfig Hosted Configuration Version resource.
1212

1313
## Example Usage
1414

15+
### Freeform
16+
17+
```terraform
18+
resource "aws_appconfig_hosted_configuration_version" "example" {
19+
application_id = aws_appconfig_application.example.id
20+
configuration_profile_id = aws_appconfig_configuration_profile.example.configuration_profile_id
21+
description = "Example Freeform Hosted Configuration Version"
22+
content_type = "application/json"
23+
24+
content = jsonencode({
25+
foo = "bar",
26+
fruit = ["apple", "pear", "orange"],
27+
isThingEnabled = true
28+
})
29+
}
30+
```
31+
32+
### Feature Flags
33+
1534
```terraform
1635
resource "aws_appconfig_hosted_configuration_version" "example" {
1736
application_id = aws_appconfig_application.example.id
1837
configuration_profile_id = aws_appconfig_configuration_profile.example.configuration_profile_id
19-
description = "Example Hosted Configuration Version"
38+
description = "Example Freeform Hosted Configuration Version"
2039
content_type = "application/json"
2140
2241
content = jsonencode({
23-
foo = "bar"
42+
flags : {
43+
foo : {
44+
name : "foo",
45+
_deprecation : {
46+
"status" : "planned"
47+
}
48+
}
49+
bar : {
50+
name : "bar",
51+
}
52+
}
53+
values : {
54+
foo : {
55+
enabled : "true",
56+
}
57+
bar : {
58+
enabled : "true",
59+
}
60+
}
61+
version : "1"
2462
})
2563
}
2664
```

0 commit comments

Comments
 (0)