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
resource "aws_s3_bucket_analytics_configuration" "bucketanalytics" {
bucket = aws_s3_bucket.bucket1.bucket
name = "bucketanalytics"
}
resource "aws_s3_bucket" "bucket1_withUsage" {
resource "aws_s3_bucket_analytics_configuration" "example-filtered" {
bucket = aws_s3_bucket.example.bucket
name = "ImportantBlueDocuments"
filter {
prefix = "documents/"
resource "aws_s3_bucket_analytics_configuration" "bucketanalytics" {
bucket = aws_s3_bucket.bucket1.bucket
name = "bucketanalytics"
}
resource "aws_s3_bucket" "bucket1_withUsage" {
resource "aws_s3_bucket_analytics_configuration" "this" {
bucket = var.bucket
name = var.name
dynamic "filter" {
for_each = var.filter
Parameters
-
bucket
required - string -
id
optional computed - string -
name
required - string -
filter
list block -
storage_class_analysis
list block-
data_export
list block-
output_schema_version
optional - string -
destination
list block-
s3_bucket_destination
list block-
bucket_account_id
optional - string -
bucket_arn
required - string -
format
optional - string -
prefix
optional - string
-
-
-
-
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.
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.
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.
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.