From 819549f7d068870a193f8cd40877169b1159e133 Mon Sep 17 00:00:00 2001 From: Justin Retzolk <44710313+justinretzolk@users.noreply.github.com> Date: Thu, 9 Jun 2022 12:04:56 -0500 Subject: [PATCH 1/4] Add validation for aws_s3_bucket_metric.name --- internal/service/s3/bucket_metric.go | 8 +++++--- website/docs/r/s3_bucket_metric.html.markdown | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/service/s3/bucket_metric.go b/internal/service/s3/bucket_metric.go index d44d545f5b3..61979387265 100644 --- a/internal/service/s3/bucket_metric.go +++ b/internal/service/s3/bucket_metric.go @@ -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" @@ -27,9 +28,10 @@ func ResourceBucketMetric() *schema.Resource { Schema: map[string]*schema.Schema{ "bucket": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringLenBetween(1, 64), }, "filter": { Type: schema.TypeList, diff --git a/website/docs/r/s3_bucket_metric.html.markdown b/website/docs/r/s3_bucket_metric.html.markdown index 8474e2ed90c..85c6540b374 100644 --- a/website/docs/r/s3_bucket_metric.html.markdown +++ b/website/docs/r/s3_bucket_metric.html.markdown @@ -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: From ed031dd5404520a20f006f8ea98492a182aebc79 Mon Sep 17 00:00:00 2001 From: Justin Retzolk <44710313+justinretzolk@users.noreply.github.com> Date: Thu, 9 Jun 2022 12:13:48 -0500 Subject: [PATCH 2/4] Add changelog entry --- .changelog/25260.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/25260.txt diff --git a/.changelog/25260.txt b/.changelog/25260.txt new file mode 100644 index 00000000000..9a95512ae4b --- /dev/null +++ b/.changelog/25260.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_s3_bucket_metric: Add validation to ensure name is <= 64 characters. +``` From ebcb9715d145d00232859a3b290f8b415c0d87d1 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Sun, 12 Jun 2022 12:44:51 +0000 Subject: [PATCH 3/4] Initial Commit - fo aws-internal-review --- internal/service/s3/bucket_metric.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/service/s3/bucket_metric.go b/internal/service/s3/bucket_metric.go index 61979387265..a40d9d04a10 100644 --- a/internal/service/s3/bucket_metric.go +++ b/internal/service/s3/bucket_metric.go @@ -54,9 +54,10 @@ func ResourceBucketMetric() *schema.Resource { }, }, "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringLenBetween(0, 64), }, }, } From 2b1449f6ccaf954dbe057956f2c437994346a0d5 Mon Sep 17 00:00:00 2001 From: Angie Pinilla Date: Tue, 21 Jun 2022 13:16:40 -0400 Subject: [PATCH 4/4] r/s3_bucket_metric: remove validation from bucket; update name validation to be minimum 1 char --- internal/service/s3/bucket_metric.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/internal/service/s3/bucket_metric.go b/internal/service/s3/bucket_metric.go index a40d9d04a10..7f72be95f07 100644 --- a/internal/service/s3/bucket_metric.go +++ b/internal/service/s3/bucket_metric.go @@ -28,10 +28,9 @@ func ResourceBucketMetric() *schema.Resource { Schema: map[string]*schema.Schema{ "bucket": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringLenBetween(1, 64), + Type: schema.TypeString, + Required: true, + ForceNew: true, }, "filter": { Type: schema.TypeList, @@ -57,7 +56,7 @@ func ResourceBucketMetric() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringLenBetween(0, 64), + ValidateFunc: validation.StringLenBetween(1, 64), }, }, }