Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/s3_bucket_metric: add atleastoneof property to filter attributes #14230

Merged
merged 1 commit into from
Jul 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions aws/resource_aws_s3_bucket_metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,16 @@ func resourceAwsS3BucketMetric() *schema.Resource {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"prefix": {
Type: schema.TypeString,
Optional: true,
Type: schema.TypeString,
Optional: true,
AtLeastOneOf: filterAtLeastOneOfKeys,
},
"tags": {
Type: schema.TypeMap,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
AtLeastOneOf: filterAtLeastOneOfKeys,
},
"tags": tagsSchema(),
},
},
},
Expand Down
4 changes: 4 additions & 0 deletions aws/resource_aws_s3_bucket_metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"
"reflect"
"regexp"
"sort"
"testing"
"time"
Expand Down Expand Up @@ -292,6 +293,8 @@ func TestAccAWSS3BucketMetric_basic(t *testing.T) {
})
}

// Reference: https://github.com/terraform-providers/terraform-provider-aws/issues/11813
// Disallow Empty filter block
func TestAccAWSS3BucketMetric_WithEmptyFilter(t *testing.T) {
var conf s3.MetricsConfiguration
rInt := acctest.RandInt()
Expand All @@ -310,6 +313,7 @@ func TestAccAWSS3BucketMetric_WithEmptyFilter(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSS3BucketMetricsConfigExists(resourceName, &conf),
),
ExpectError: regexp.MustCompile(`config is invalid`),
},
},
})
Expand Down
25 changes: 25 additions & 0 deletions website/docs/guides/version-3-upgrade.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Upgrade topics:
- [Resource: aws_lb_listener_rule](#resource-aws_lb_listener_rule)
- [Resource: aws_msk_cluster](#resource-aws_msk_cluster)
- [Resource: aws_s3_bucket](#resource-aws_s3_bucket)
- [Resource: aws_s3_bucket_metric](#resource-aws_s3_bucket_metric)
- [Resource: aws_security_group](#resource-aws_security_group)
- [Resource: aws_sns_platform_application](#resource-aws_sns_platform_application)
- [Resource: aws_spot_fleet_request](#resource-aws_spot_fleet_request)
Expand Down Expand Up @@ -503,6 +504,30 @@ resource "aws_s3_bucket" "example" {
}
```

## Resource: aws_s3_bucket_metric

### filter configuration block Plan-Time Validation Change

The `filter` configuration block no longer supports the empty block `{}` and requires at least one of the `prefix` or `tags` attributes to be specified.

For example, given this previous configuration:

```hcl
resource "aws_s3_bucket_metric" "example" {
# ... other configuration ...

filter {}
}
```

An updated configuration:

```hcl
resource "aws_s3_bucket_metric" "example" {
# ... other configuration ...
}
```

## Resource: aws_security_group

### Removal of Automatic aws_security_group_rule Import
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/s3_bucket_metric.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ The following arguments are supported:

The `filter` metric configuration supports the following:

~> **NOTE**: At least one of `prefix` or `tags` is required when specifying a `filter`

* `prefix` - (Optional) Object prefix for filtering (singular).
* `tags` - (Optional) Object tags for filtering (up to 10).

Expand Down