Skip to content

Commit

Permalink
Merge pull request #25260 from hashicorp/b-aws_s3_bucket_metric-name-…
Browse files Browse the repository at this point in the history
…validation

Add validation for `aws_s3_bucket_metric.name`
  • Loading branch information
anGie44 authored Jun 21, 2022
2 parents 9d18195 + 2b1449f commit fb3807d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .changelog/25260.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_s3_bucket_metric: Add validation to ensure name is <= 64 characters.
```
8 changes: 5 additions & 3 deletions internal/service/s3/bucket_metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/hashicorp/terraform-provider-aws/internal/conns"
tftags "github.com/hashicorp/terraform-provider-aws/internal/tags"
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
Expand Down Expand Up @@ -52,9 +53,10 @@ func ResourceBucketMetric() *schema.Resource {
},
},
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringLenBetween(1, 64),
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/s3_bucket_metric.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ resource "aws_s3_bucket_metric" "example-filtered" {
The following arguments are supported:

* `bucket` - (Required) The name of the bucket to put metric configuration.
* `name` - (Required) Unique identifier of the metrics configuration for the bucket.
* `name` - (Required) Unique identifier of the metrics configuration for the bucket. Must be less than or equal to 64 characters in length.
* `filter` - (Optional) [Object filtering](http://docs.aws.amazon.com/AmazonS3/latest/dev/metrics-configurations.html#metrics-configurations-filter) that accepts a prefix, tags, or a logical AND of prefix and tags (documented below).

The `filter` metric configuration supports the following:
Expand Down

0 comments on commit fb3807d

Please sign in to comment.