AWS Amazon S3 Bucket Analytics Configuration

This page shows how to write Terraform and CloudFormation for Amazon S3 Bucket Analytics Configuration and write them securely.

aws_s3_bucket_analytics_configuration (Terraform)

The Bucket Analytics Configuration in Amazon S3 can be configured in Terraform with the resource name aws_s3_bucket_analytics_configuration. The following sections describe 4 examples of how to use the resource and its parameters.

Example Usage from GitHub

s3_bucket_analytics_configuration_test.tf#L16
resource "aws_s3_bucket_analytics_configuration" "bucketanalytics" {
  bucket = aws_s3_bucket.bucket1.bucket
  name   = "bucketanalytics"
}

resource "aws_s3_bucket" "bucket1_withUsage" {
template.tf#L5
resource "aws_s3_bucket_analytics_configuration" "example-filtered" {
  bucket = aws_s3_bucket.example.bucket
  name   = "ImportantBlueDocuments"

  filter {
    prefix = "documents/"
s3_bucket_analytics_configuration_test.tf#L16
resource "aws_s3_bucket_analytics_configuration" "bucketanalytics" {
  bucket = aws_s3_bucket.bucket1.bucket
  name   = "bucketanalytics"
}

resource "aws_s3_bucket" "bucket1_withUsage" {
main.tf#L7
resource "aws_s3_bucket_analytics_configuration" "this" {
  bucket = var.bucket
  name   = var.name

  dynamic "filter" {
    for_each = var.filter

Review your Terraform file for AWS best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Provides a S3 bucket analytics configuration resource.

Tips: Best Practices for The Other AWS Amazon S3 Resources

In addition to the aws_s3_bucket_public_access_block, AWS Amazon S3 has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.

risk-label

aws_s3_bucket_public_access_block

Ensure S3 bucket-level Public Access Block restricts public bucket policies

It is better to enable S3 bucket-level Public Access Block if you don't need public buckets.

risk-label

aws_s3_bucket

Ensure S3 bucket access policy is well configured

It is better to configure the S3 bucket access policy properly to limit it unless explicitly required.

Review your AWS Amazon S3 settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

AWS::S3::Bucket AnalyticsConfiguration (CloudFormation)

The Bucket AnalyticsConfiguration in S3 can be configured in CloudFormation with the resource name AWS::S3::Bucket AnalyticsConfiguration. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

An example could not be found in GitHub.

Parameters

Id The ID that identifies the analytics configuration.
Required: Yes
Type: String
Update requires: No interruption

Prefix The prefix that an object must have to be included in the analytics results.
Required: No
Type: String
Update requires: No interruption

StorageClassAnalysis Contains data related to access patterns to be collected and made available to analyze the tradeoffs between different storage classes.
Required: Yes
Type: StorageClassAnalysis
Update requires: No interruption

TagFilters The tags to use when evaluating an analytics filter.
The analytics only includes objects that meet the filter's criteria. If no filter is specified, all of the contents of the bucket are included in the analysis.
Required: No
Type: List of TagFilter
Update requires: No interruption

Explanation in CloudFormation Registry

Specifies the configuration and any analyses for the analytics filter of an Amazon S3 bucket.

Frequently asked questions

What is AWS Amazon S3 Bucket Analytics Configuration?

AWS Amazon S3 Bucket Analytics Configuration is a resource for Amazon S3 of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS Amazon S3 Bucket Analytics Configuration?

For Terraform, the gilyas/infracost, cpodieu1/Hello-Word and infracost/infracost source code examples are useful. See the Terraform Example section for further details.