Skip to content

Commit

Permalink
Merge pull request #14230 from terraform-providers/b-s3-bucket-mtric-…
Browse files Browse the repository at this point in the history
…filter

resource/s3_bucket_metric: add atleastoneof property to filter attributes
  • Loading branch information
anGie44 committed Jul 23, 2020
2 parents 029fe81 + eff1528 commit fd634b9
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
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 @@ -34,6 +34,7 @@ Upgrade topics:
- [Resource: aws_msk_cluster](#resource-aws_msk_cluster)
- [Resource: aws_rds_cluster](#resource-aws_rds_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 @@ -517,6 +518,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

0 comments on commit fd634b9

Please sign in to comment.