Resource: aws_s3_bucket

Provides a S3 bucket resource.

Example Usage

Private Bucket With Tags

resource "aws_s3_bucket" "example" {
  bucket = "my-tf-test-bucket"

  tags = {
    Name        = "My bucket"
    Environment = "Dev"
  }
}

Argument Reference

This resource supports the following arguments:

The following arguments are deprecated, and will be removed in a future major version:

CORS Rule

The cors_rule configuration block supports the following arguments:

Grant

The grant configuration block supports the following arguments:

Lifecycle Rule

The lifecycle_rule configuration block supports the following arguments:

Expiration

The expiration configuration block supports the following arguments:

Transition

The transition configuration block supports the following arguments:

Noncurrent Version Expiration

The noncurrent_version_expiration configuration block supports the following arguments:

Noncurrent Version Transition

The noncurrent_version_transition configuration supports the following arguments:

Logging

The logging configuration block supports the following arguments:

Object Lock Configuration

The object_lock_configuration configuration block supports the following arguments:

Rule

The rule configuration block supports the following argument:

Default Retention

The default_retention configuration block supports the following arguments:

Replication Configuration

The replication_configuration configuration block supports the following arguments:

Rules

The rules configuration block supports the following arguments:

Filter

The filter configuration block supports the following arguments:

Destination

The destination configuration block supports the following arguments:

access_control_translation Block

The access_control_translation configuration block supports the following arguments:

Replication Time

The replication_time configuration block supports the following arguments:

Metrics

The metrics configuration block supports the following arguments:

Source Selection Criteria

The source_selection_criteria configuration block supports the following argument:

SSE KMS Encrypted Objects

The sse_kms_encrypted_objects configuration block supports the following argument:

Server Side Encryption Configuration

The server_side_encryption_configuration configuration block supports the following argument:

The rule configuration block supports the following arguments:

The apply_server_side_encryption_by_default configuration block supports the following arguments:

Versioning

The versioning configuration block supports the following arguments:

Website

The website configuration block supports the following arguments:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Timeouts

Configuration options:

Import

In Terraform v1.5.0 and later, use an import block to import S3 bucket using the bucket. For example:

import {
  to = aws_s3_bucket.bucket
  id = "bucket-name"
}

Using terraform import, import S3 bucket using the bucket. For example:

% terraform import aws_s3_bucket.bucket bucket-name