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. +``` diff --git a/internal/service/s3/bucket_metric.go b/internal/service/s3/bucket_metric.go index d44d545f5b3..7f72be95f07 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" @@ -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), }, }, } 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: