Get a detailed overview of this resourceList the top 5 use cases for this resourceBuild a program using aws.s3.BucketLoggingRepositoryAWS Classic pulumi/pulumi-awsLicenseApache-2.0NotesThis Pulumi package is based on the aws Terraform Provider.
AWS v7.32.0, May 29 26
AWS v7.32.0, May 29 26
Viewing docs for AWS v7.32.0
published on Friday, May 29, 2026 by Pulumi
v7.32.0 (7.x, latest)v6.83.1 (6.x)v5.43.0 (5.x)
aws.s3.BucketLogging Anchor
Explore with Neo
Explain this resource Show real-world scenarios Provision a new instance
Viewing docs for AWS v7.32.0
published on Friday, May 29, 2026 by Pulumi
v7.32.0 (7.x, latest)v6.83.1 (6.x)v5.43.0 (5.x)
On this page
On this page
Copy Page
[Scroll to top](/content/registry/packages/aws/api-docs/s3/bucketlogging/# "Scroll to top"/index.html)
Provides an S3 bucket (server access) logging resource. For more information, see Logging requests using server access logging in the AWS S3 User Guide.
Note: Amazon S3 supports server access logging, AWS CloudTrail, or a combination of both. Refer to the Logging options for Amazon S3 to decide which method meets your requirements.
This resource cannot be used with S3 directory buckets.
Example Usage Anchor
Grant permission by using bucket policy Anchor
- TypeScript
- Python
- Go
- C#
- Java
- YAML
- HCL PREVIEW
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const current = aws.getCallerIdentity({});
const logging = new aws.s3.Bucket("logging", {bucket: "access-logging-bucket"});
const loggingBucketPolicy = aws.iam.getPolicyDocumentOutput({
statements: [{\
principals: [{\
identifiers: ["logging.s3.amazonaws.com"],\
type: "Service",\
}],\
actions: ["s3:PutObject"],\
resources: [pulumi.interpolate`${logging.arn}/*`],\
conditions: [{\
test: "StringEquals",\
variable: "aws:SourceAccount",\
values: [current.then(current => current.accountId)],\
}],\
}],
});
const loggingBucketPolicy2 = new aws.s3.BucketPolicy("logging", {
bucket: logging.bucket,
policy: loggingBucketPolicy.apply(loggingBucketPolicy => loggingBucketPolicy.json),
});
const example = new aws.s3.Bucket("example", {bucket: "example-bucket"});
const exampleBucketLogging = new aws.s3.BucketLogging("example", {
bucket: example.bucket,
targetBucket: logging.bucket,
targetPrefix: "log/",
targetObjectKeyFormat: {
partitionedPrefix: {
partitionDateSource: "EventTime",
},
},
});
Copy
import pulumi
import pulumi_aws as aws
current = aws.get_caller_identity()
logging = aws.s3.Bucket("logging", bucket="access-logging-bucket")
logging_bucket_policy = aws.iam.get_policy_document_output(statements=[{\
"principals": [{\
"identifiers": ["logging.s3.amazonaws.com"],\
"type": "Service",\
}],\
"actions": ["s3:PutObject"],\
"resources": [logging.arn.apply(lambda arn: f"{arn}/*")],\
"conditions": [{\
"test": "StringEquals",\
"variable": "aws:SourceAccount",\
"values": [current.account_id],\
}],\
}])
logging_bucket_policy2 = aws.s3.BucketPolicy("logging",
bucket=logging.bucket,
policy=logging_bucket_policy.json)
example = aws.s3.Bucket("example", bucket="example-bucket")
example_bucket_logging = aws.s3.BucketLogging("example",
bucket=example.bucket,
target_bucket=logging.bucket,
target_prefix="log/",
target_object_key_format={
"partitioned_prefix": {
"partition_date_source": "EventTime",
},
})
Copy
package main
import (
"fmt"
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws"
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/s3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
current, err := aws.GetCallerIdentity(ctx, &aws.GetCallerIdentityArgs{}, nil)
if err != nil {
return err
}
logging, err := s3.NewBucket(ctx, "logging", &s3.BucketArgs{
Bucket: pulumi.String("access-logging-bucket"),
})
if err != nil {
return err
}
loggingBucketPolicy := iam.GetPolicyDocumentOutput(ctx, iam.GetPolicyDocumentOutputArgs{
Statements: iam.GetPolicyDocumentStatementArray{
&iam.GetPolicyDocumentStatementArgs{
Principals: iam.GetPolicyDocumentStatementPrincipalArray{
&iam.GetPolicyDocumentStatementPrincipalArgs{
Identifiers: pulumi.StringArray{
pulumi.String("logging.s3.amazonaws.com"),
},
Type: pulumi.String("Service"),
},
},
Actions: pulumi.StringArray{
pulumi.String("s3:PutObject"),
},
Resources: pulumi.StringArray{
logging.Arn.ApplyT(func(arn string) (string, error) {
return fmt.Sprintf("%v/*", arn), nil
}).(pulumi.StringOutput),
},
Conditions: iam.GetPolicyDocumentStatementConditionArray{
&iam.GetPolicyDocumentStatementConditionArgs{
Test: pulumi.String("StringEquals"),
Variable: pulumi.String("aws:SourceAccount"),
Values: pulumi.StringArray{
pulumi.String(current.AccountId),
},
},
},
},
},
}, nil)
_, err = s3.NewBucketPolicy(ctx, "logging", &s3.BucketPolicyArgs{
Bucket: logging.Bucket,
Policy: pulumi.String(loggingBucketPolicy.ApplyT(func(loggingBucketPolicy iam.GetPolicyDocumentResult) (*string, error) {
return &loggingBucketPolicy.Json, nil
}).(pulumi.StringPtrOutput)),
})
if err != nil {
return err
}
example, err := s3.NewBucket(ctx, "example", &s3.BucketArgs{
Bucket: pulumi.String("example-bucket"),
})
if err != nil {
return err
}
_, err = s3.NewBucketLogging(ctx, "example", &s3.BucketLoggingArgs{
Bucket: example.Bucket,
TargetBucket: logging.Bucket,
TargetPrefix: pulumi.String("log/"),
TargetObjectKeyFormat: &s3.BucketLoggingTargetObjectKeyFormatArgs{
PartitionedPrefix: &s3.BucketLoggingTargetObjectKeyFormatPartitionedPrefixArgs{
PartitionDateSource: pulumi.String("EventTime"),
},
},
})
if err != nil {
return err
}
return nil
})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var current = Aws.GetCallerIdentity.Invoke();
var logging = new Aws.S3.Bucket("logging", new()
{
BucketName = "access-logging-bucket",
});
var loggingBucketPolicy = Aws.Iam.GetPolicyDocument.Invoke(new()
{
Statements = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
{
Principals = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
{
Identifiers = new[]
{
"logging.s3.amazonaws.com",
},
Type = "Service",
},
},
Actions = new[]
{
"s3:PutObject",
},
Resources = new[]
{
$"{logging.Arn}/*",
},
Conditions = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
{
Test = "StringEquals",
Variable = "aws:SourceAccount",
Values = new[]
{
current.Apply(getCallerIdentityResult => getCallerIdentityResult.AccountId),
},
},
},
},
},
});
var loggingBucketPolicy2 = new Aws.S3.BucketPolicy("logging", new()
{
Bucket = logging.BucketName,
Policy = loggingBucketPolicy.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
});
var example = new Aws.S3.Bucket("example", new()
{
BucketName = "example-bucket",
});
var exampleBucketLogging = new Aws.S3.BucketLogging("example", new()
{
Bucket = example.BucketName,
TargetBucket = logging.BucketName,
TargetPrefix = "log/",
TargetObjectKeyFormat = new Aws.S3.Inputs.BucketLoggingTargetObjectKeyFormatArgs
{
PartitionedPrefix = new Aws.S3.Inputs.BucketLoggingTargetObjectKeyFormatPartitionedPrefixArgs
{
PartitionDateSource = "EventTime",
},
},
});
});
Copy
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.AwsFunctions;
import com.pulumi.aws.inputs.GetCallerIdentityArgs;
import com.pulumi.aws.s3.Bucket;
import com.pulumi.aws.s3.BucketArgs;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.s3.BucketPolicy;
import com.pulumi.aws.s3.BucketPolicyArgs;
import com.pulumi.aws.s3.BucketLogging;
import com.pulumi.aws.s3.BucketLoggingArgs;
import com.pulumi.aws.s3.inputs.BucketLoggingTargetObjectKeyFormatArgs;
import com.pulumi.aws.s3.inputs.BucketLoggingTargetObjectKeyFormatPartitionedPrefixArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var current = AwsFunctions.getCallerIdentity(GetCallerIdentityArgs.builder()
.build());
var logging = new Bucket("logging", BucketArgs.builder()
.bucket("access-logging-bucket")
.build());
final var loggingBucketPolicy = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
.statements(GetPolicyDocumentStatementArgs.builder()
.principals(GetPolicyDocumentStatementPrincipalArgs.builder()
.identifiers("logging.s3.amazonaws.com")
.type("Service")
.build())
.actions("s3:PutObject")
.resources(logging.arn().applyValue(_arn -> String.format("%s/*", _arn)))
.conditions(GetPolicyDocumentStatementConditionArgs.builder()
.test("StringEquals")
.variable("aws:SourceAccount")
.values(current.accountId())
.build())
.build())
.build());
var loggingBucketPolicy2 = new BucketPolicy("loggingBucketPolicy2", BucketPolicyArgs.builder()
.bucket(logging.bucket())
.policy(loggingBucketPolicy.applyValue(_loggingBucketPolicy -> _loggingBucketPolicy.json()))
.build());
var example = new Bucket("example", BucketArgs.builder()
.bucket("example-bucket")
.build());
var exampleBucketLogging = new BucketLogging("exampleBucketLogging", BucketLoggingArgs.builder()
.bucket(example.bucket())
.targetBucket(logging.bucket())
.targetPrefix("log/")
.targetObjectKeyFormat(BucketLoggingTargetObjectKeyFormatArgs.builder()
.partitionedPrefix(BucketLoggingTargetObjectKeyFormatPartitionedPrefixArgs.builder()
.partitionDateSource("EventTime")
.build())
.build())
.build());
}
}
Copy
resources:
logging:
type: aws:s3:Bucket
properties:
bucket: access-logging-bucket
loggingBucketPolicy2:
type: aws:s3:BucketPolicy
name: logging
properties:
bucket: ${logging.bucket}
policy: ${loggingBucketPolicy.json}
example:
type: aws:s3:Bucket
properties:
bucket: example-bucket
exampleBucketLogging:
type: aws:s3:BucketLogging
name: example
properties:
bucket: ${example.bucket}
targetBucket: ${logging.bucket}
targetPrefix: log/
targetObjectKeyFormat:
partitionedPrefix:
partitionDateSource: EventTime
variables:
current:
fn::invoke:
function: aws:getCallerIdentity
arguments: {}
loggingBucketPolicy:
fn::invoke:
function: aws:iam:getPolicyDocument
arguments:
statements:
- principals:
- identifiers:
- logging.s3.amazonaws.com
type: Service
actions:
- s3:PutObject
resources:
- ${logging.arn}/*
conditions:
- test: StringEquals
variable: aws:SourceAccount
values:
- ${current.accountId}
Copy
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
data "aws_getcalleridentity" "current" {
}
data "aws_iam_getpolicydocument" "loggingBucketPolicy" {
statements {
principals {
identifiers = ["logging.s3.amazonaws.com"]
type = "Service"
}
actions = ["s3:PutObject"]
resources = ["${aws_s3_bucket.logging.arn}/*"]
conditions {
test = "StringEquals"
variable = "aws:SourceAccount"
values = [data.aws_getcalleridentity.current.account_id]
}
}
}
resource "aws_s3_bucket" "logging" {
bucket = "access-logging-bucket"
}
resource "aws_s3_bucketpolicy" "logging" {
bucket = aws_s3_bucket.logging.bucket
policy = data.aws_iam_getpolicydocument.loggingBucketPolicy.json
}
resource "aws_s3_bucket" "example" {
bucket = "example-bucket"
}
resource "aws_s3_bucketlogging" "example" {
bucket = aws_s3_bucket.example.bucket
target_bucket = aws_s3_bucket.logging.bucket
target_prefix = "log/"
target_object_key_format = {
partitioned_prefix = {
partition_date_source = "EventTime"
}
}
}
Copy
Grant permission by using bucket ACL Anchor
The AWS Documentation does not recommend using the ACL.
- TypeScript
- Python
- Go
- C#
- Java
- YAML
- HCL PREVIEW
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.s3.Bucket("example", {bucket: "my-tf-example-bucket"});
const exampleBucketAcl = new aws.s3.BucketAcl("example", {
bucket: example.id,
acl: "private",
});
const logBucket = new aws.s3.Bucket("log_bucket", {bucket: "my-tf-log-bucket"});
const logBucketAcl = new aws.s3.BucketAcl("log_bucket_acl", {
bucket: logBucket.id,
acl: "log-delivery-write",
});
const exampleBucketLogging = new aws.s3.BucketLogging("example", {
bucket: example.id,
targetBucket: logBucket.id,
targetPrefix: "log/",
});
Copy
import pulumi
import pulumi_aws as aws
example = aws.s3.Bucket("example", bucket="my-tf-example-bucket")
example_bucket_acl = aws.s3.BucketAcl("example",
bucket=example.id,
acl="private")
log_bucket = aws.s3.Bucket("log_bucket", bucket="my-tf-log-bucket")
log_bucket_acl = aws.s3.BucketAcl("log_bucket_acl",
bucket=log_bucket.id,
acl="log-delivery-write")
example_bucket_logging = aws.s3.BucketLogging("example",
bucket=example.id,
target_bucket=log_bucket.id,
target_prefix="log/")
Copy
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/s3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := s3.NewBucket(ctx, "example", &s3.BucketArgs{
Bucket: pulumi.String("my-tf-example-bucket"),
})
if err != nil {
return err
}
_, err = s3.NewBucketAcl(ctx, "example", &s3.BucketAclArgs{
Bucket: example.ID(),
Acl: pulumi.String("private"),
})
if err != nil {
return err
}
logBucket, err := s3.NewBucket(ctx, "log_bucket", &s3.BucketArgs{
Bucket: pulumi.String("my-tf-log-bucket"),
})
if err != nil {
return err
}
_, err = s3.NewBucketAcl(ctx, "log_bucket_acl", &s3.BucketAclArgs{
Bucket: logBucket.ID(),
Acl: pulumi.String("log-delivery-write"),
})
if err != nil {
return err
}
_, err = s3.NewBucketLogging(ctx, "example", &s3.BucketLoggingArgs{
Bucket: example.ID(),
TargetBucket: logBucket.ID(),
TargetPrefix: pulumi.String("log/"),
})
if err != nil {
return err
}
return nil
})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.S3.Bucket("example", new()
{
BucketName = "my-tf-example-bucket",
});
var exampleBucketAcl = new Aws.S3.BucketAcl("example", new()
{
Bucket = example.Id,
Acl = "private",
});
var logBucket = new Aws.S3.Bucket("log_bucket", new()
{
BucketName = "my-tf-log-bucket",
});
var logBucketAcl = new Aws.S3.BucketAcl("log_bucket_acl", new()
{
Bucket = logBucket.Id,
Acl = "log-delivery-write",
});
var exampleBucketLogging = new Aws.S3.BucketLogging("example", new()
{
Bucket = example.Id,
TargetBucket = logBucket.Id,
TargetPrefix = "log/",
});
});
Copy
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.s3.Bucket;
import com.pulumi.aws.s3.BucketArgs;
import com.pulumi.aws.s3.BucketAcl;
import com.pulumi.aws.s3.BucketAclArgs;
import com.pulumi.aws.s3.BucketLogging;
import com.pulumi.aws.s3.BucketLoggingArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new Bucket("example", BucketArgs.builder()
.bucket("my-tf-example-bucket")
.build());
var exampleBucketAcl = new BucketAcl("exampleBucketAcl", BucketAclArgs.builder()
.bucket(example.id())
.acl("private")
.build());
var logBucket = new Bucket("logBucket", BucketArgs.builder()
.bucket("my-tf-log-bucket")
.build());
var logBucketAcl = new BucketAcl("logBucketAcl", BucketAclArgs.builder()
.bucket(logBucket.id())
.acl("log-delivery-write")
.build());
var exampleBucketLogging = new BucketLogging("exampleBucketLogging", BucketLoggingArgs.builder()
.bucket(example.id())
.targetBucket(logBucket.id())
.targetPrefix("log/")
.build());
}
}
Copy
resources:
example:
type: aws:s3:Bucket
properties:
bucket: my-tf-example-bucket
exampleBucketAcl:
type: aws:s3:BucketAcl
name: example
properties:
bucket: ${example.id}
acl: private
logBucket:
type: aws:s3:Bucket
name: log_bucket
properties:
bucket: my-tf-log-bucket
logBucketAcl:
type: aws:s3:BucketAcl
name: log_bucket_acl
properties:
bucket: ${logBucket.id}
acl: log-delivery-write
exampleBucketLogging:
type: aws:s3:BucketLogging
name: example
properties:
bucket: ${example.id}
targetBucket: ${logBucket.id}
targetPrefix: log/
Copy
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
resource "aws_s3_bucket" "example" {
bucket = "my-tf-example-bucket"
}
resource "aws_s3_bucketacl" "example" {
bucket = aws_s3_bucket.example.id
acl = "private"
}
resource "aws_s3_bucket" "log_bucket" {
bucket = "my-tf-log-bucket"
}
resource "aws_s3_bucketacl" "log_bucket_acl" {
bucket = aws_s3_bucket.log_bucket.id
acl = "log-delivery-write"
}
resource "aws_s3_bucketlogging" "example" {
bucket = aws_s3_bucket.example.id
target_bucket = aws_s3_bucket.log_bucket.id
target_prefix = "log/"
}
Copy
Create BucketLogging Resource Anchor
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax Anchor
- TypeScript
- Python
- Go
- C#
- Java
- YAML
- HCL PREVIEW
new BucketLogging(name: string, args: BucketLoggingArgs, opts?: CustomResourceOptions);
@overload
def BucketLogging(resource_name: str,
args: BucketLoggingInitArgs,
opts: Optional[ResourceOptions] = None)
@overload
def BucketLogging(resource_name: str,
opts: Optional[ResourceOptions] = None,
bucket: Optional[str] = None,
target_bucket: Optional[str] = None,
target_prefix: Optional[str] = None,
expected_bucket_owner: Optional[str] = None,
region: Optional[str] = None,
target_grants: Optional[Sequence[BucketLoggingTargetGrantArgs]] = None,
target_object_key_format: Optional[BucketLoggingTargetObjectKeyFormatArgs] = None)
func NewBucketLogging(ctx *Context, name string, args BucketLoggingArgs, opts ...ResourceOption) (*BucketLogging, error)
public BucketLogging(string name, BucketLoggingArgs args, CustomResourceOptions? opts = null)
public BucketLogging(String name, BucketLoggingArgs args)
public BucketLogging(String name, BucketLoggingArgs args, CustomResourceOptions options)
type: aws:s3:BucketLogging
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
resource "aws_s3_bucketlogging" "name" {
# resource properties
}
Parameters Anchor
nameThis property is required.stringThe unique name of the resource.argsThis property is required.BucketLoggingArgsThe arguments to resource properties.optsCustomResourceOptionsBag of options to control resource's behavior.
resource_nameThis property is required.strThe unique name of the resource.argsThis property is required.BucketLoggingInitArgsThe arguments to resource properties.optsResourceOptionsBag of options to control resource's behavior.
ctxContextContext object for the current deployment.nameThis property is required.stringThe unique name of the resource.argsThis property is required.BucketLoggingArgsThe arguments to resource properties.optsResourceOptionBag of options to control resource's behavior.
nameThis property is required.stringThe unique name of the resource.argsThis property is required.BucketLoggingArgsThe arguments to resource properties.optsCustomResourceOptionsBag of options to control resource's behavior.
nameThis property is required.StringThe unique name of the resource.argsThis property is required.BucketLoggingArgsThe arguments to resource properties.optionsCustomResourceOptionsBag of options to control resource's behavior.
Constructor example Anchor
The following reference example uses placeholder values for all input properties.
- TypeScript
- Python
- Go
- C#
- Java
- YAML
- HCL PREVIEW
var bucketLoggingResource = new Aws.S3.BucketLogging("bucketLoggingResource", new()
{
Bucket = "string",
TargetBucket = "string",
TargetPrefix = "string",
Region = "string",
TargetGrants = new[]
{
new Aws.S3.Inputs.BucketLoggingTargetGrantArgs
{
Grantee = new Aws.S3.Inputs.BucketLoggingTargetGrantGranteeArgs
{
Type = "string",
EmailAddress = "string",
Id = "string",
Uri = "string",
},
Permission = "string",
},
},
TargetObjectKeyFormat = new Aws.S3.Inputs.BucketLoggingTargetObjectKeyFormatArgs
{
PartitionedPrefix = new Aws.S3.Inputs.BucketLoggingTargetObjectKeyFormatPartitionedPrefixArgs
{
PartitionDateSource = "string",
},
SimplePrefix = null,
},
});
Copy
example, err := s3.NewBucketLogging(ctx, "bucketLoggingResource", &s3.BucketLoggingArgs{
Bucket: pulumi.String("string"),
TargetBucket: pulumi.String("string"),
TargetPrefix: pulumi.String("string"),
Region: pulumi.String("string"),
TargetGrants: s3.BucketLoggingTargetGrantArray{
&s3.BucketLoggingTargetGrantArgs{
Grantee: &s3.BucketLoggingTargetGrantGranteeArgs{
Type: pulumi.String("string"),
EmailAddress: pulumi.String("string"),
Id: pulumi.String("string"),
Uri: pulumi.String("string"),
},
Permission: pulumi.String("string"),
},
},
TargetObjectKeyFormat: &s3.BucketLoggingTargetObjectKeyFormatArgs{
PartitionedPrefix: &s3.BucketLoggingTargetObjectKeyFormatPartitionedPrefixArgs{
PartitionDateSource: pulumi.String("string"),
},
SimplePrefix: &s3.BucketLoggingTargetObjectKeyFormatSimplePrefixArgs{},
},
})
Copy
resource "aws_s3_bucketlogging" "bucketLoggingResource" {
bucket = "string"
target_bucket = "string"
target_prefix = "string"
region = "string"
target_grants {
grantee = {
type = "string"
email_address = "string"
id = "string"
uri = "string"
}
permission = "string"
}
target_object_key_format = {
partitioned_prefix = {
partition_date_source = "string"
}
simple_prefix = {}
}
}
Copy
var bucketLoggingResource = new BucketLogging("bucketLoggingResource", BucketLoggingArgs.builder()
.bucket("string")
.targetBucket("string")
.targetPrefix("string")
.region("string")
.targetGrants(BucketLoggingTargetGrantArgs.builder()
.grantee(BucketLoggingTargetGrantGranteeArgs.builder()
.type("string")
.emailAddress("string")
.id("string")
.uri("string")
.build())
.permission("string")
.build())
.targetObjectKeyFormat(BucketLoggingTargetObjectKeyFormatArgs.builder()
.partitionedPrefix(BucketLoggingTargetObjectKeyFormatPartitionedPrefixArgs.builder()
.partitionDateSource("string")
.build())
.simplePrefix(BucketLoggingTargetObjectKeyFormatSimplePrefixArgs.builder()
.build())
.build())
.build());
Copy
bucket_logging_resource = aws.s3.BucketLogging("bucketLoggingResource",
bucket="string",
target_bucket="string",
target_prefix="string",
region="string",
target_grants=[{\
"grantee": {\
"type": "string",\
"email_address": "string",\
"id": "string",\
"uri": "string",\
},\
"permission": "string",\
}],
target_object_key_format={
"partitioned_prefix": {
"partition_date_source": "string",
},
"simple_prefix": {},
})
Copy
const bucketLoggingResource = new aws.s3.BucketLogging("bucketLoggingResource", {
bucket: "string",
targetBucket: "string",
targetPrefix: "string",
region: "string",
targetGrants: [{\
grantee: {\
type: "string",\
emailAddress: "string",\
id: "string",\
uri: "string",\
},\
permission: "string",\
}],
targetObjectKeyFormat: {
partitionedPrefix: {
partitionDateSource: "string",
},
simplePrefix: {},
},
});
Copy
type: aws:s3:BucketLogging
properties:
bucket: string
region: string
targetBucket: string
targetGrants:
- grantee:
emailAddress: string
id: string
type: string
uri: string
permission: string
targetObjectKeyFormat:
partitionedPrefix:
partitionDateSource: string
simplePrefix: {}
targetPrefix: string
Copy
BucketLogging Resource Properties Anchor
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs Anchor
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The BucketLogging resource accepts the following input properties:
This property is required.
Changes to this property will trigger replacement.
stringName of the bucket.TargetBucketThis property is required.stringName of the bucket where you want Amazon S3 to store server access logs.TargetPrefixThis property is required.stringPrefix for all log object keys.ExpectedBucketOwnerstringAccount ID of the expected bucket owner.
Deprecated: expected_bucket_owner is deprecated. It will be removed in a future verion of the provider.
RegionstringRegion where this resource will be managed. Defaults to the Region set in the provider configuration.TargetGrantsList
This property is required.
Changes to this property will trigger replacement.
stringName of the bucket.TargetBucketThis property is required.stringName of the bucket where you want Amazon S3 to store server access logs.TargetPrefixThis property is required.stringPrefix for all log object keys.ExpectedBucketOwnerstringAccount ID of the expected bucket owner.
Deprecated: expected_bucket_owner is deprecated. It will be removed in a future verion of the provider.
RegionstringRegion where this resource will be managed. Defaults to the Region set in the provider configuration.TargetGrants[]BucketLoggingTargetGrantArgsSet of configuration blocks with information for granting permissions. See below.TargetObjectKeyFormatBucketLoggingTargetObjectKeyFormatArgsAmazon S3 key format for log objects. See below.
This property is required.
Changes to this property will trigger replacement.
stringName of the bucket.target_bucketThis property is required.stringName of the bucket where you want Amazon S3 to store server access logs.target_prefixThis property is required.stringPrefix for all log object keys.expected_bucket_ownerstringAccount ID of the expected bucket owner.
Deprecated: expected_bucket_owner is deprecated. It will be removed in a future verion of the provider.
regionstringRegion where this resource will be managed. Defaults to the Region set in the provider configuration.target_grantslist(object)Set of configuration blocks with information for granting permissions. See below.target_object_key_formatobjectAmazon S3 key format for log objects. See below.
This property is required.
Changes to this property will trigger replacement.
StringName of the bucket.targetBucketThis property is required.StringName of the bucket where you want Amazon S3 to store server access logs.targetPrefixThis property is required.StringPrefix for all log object keys.expectedBucketOwnerStringAccount ID of the expected bucket owner.
Deprecated: expected_bucket_owner is deprecated. It will be removed in a future verion of the provider.
regionStringRegion where this resource will be managed. Defaults to the Region set in the provider configuration.targetGrantsList
This property is required.
Changes to this property will trigger replacement.
stringName of the bucket.targetBucketThis property is required.stringName of the bucket where you want Amazon S3 to store server access logs.targetPrefixThis property is required.stringPrefix for all log object keys.expectedBucketOwnerstringAccount ID of the expected bucket owner.
Deprecated: expected_bucket_owner is deprecated. It will be removed in a future verion of the provider.
regionstringRegion where this resource will be managed. Defaults to the Region set in the provider configuration.targetGrantsBucketLoggingTargetGrant[]Set of configuration blocks with information for granting permissions. See below.targetObjectKeyFormatBucketLoggingTargetObjectKeyFormatAmazon S3 key format for log objects. See below.
This property is required.
Changes to this property will trigger replacement.
strName of the bucket.target_bucketThis property is required.strName of the bucket where you want Amazon S3 to store server access logs.target_prefixThis property is required.strPrefix for all log object keys.expected_bucket_ownerstrAccount ID of the expected bucket owner.
Deprecated: expected_bucket_owner is deprecated. It will be removed in a future verion of the provider.
regionstrRegion where this resource will be managed. Defaults to the Region set in the provider configuration.target_grantsSequence[BucketLoggingTargetGrantArgs]Set of configuration blocks with information for granting permissions. See below.target_object_key_formatBucketLoggingTargetObjectKeyFormatArgsAmazon S3 key format for log objects. See below.
This property is required.
Changes to this property will trigger replacement.
StringName of the bucket.targetBucketThis property is required.StringName of the bucket where you want Amazon S3 to store server access logs.targetPrefixThis property is required.StringPrefix for all log object keys.expectedBucketOwnerStringAccount ID of the expected bucket owner.
Deprecated: expected_bucket_owner is deprecated. It will be removed in a future verion of the provider.
regionStringRegion where this resource will be managed. Defaults to the Region set in the provider configuration.targetGrantsList
Outputs Anchor
All input properties are implicitly available as output properties. Additionally, the BucketLogging resource produces the following output properties:
IdstringThe provider-assigned unique ID for this managed resource.
IdstringThe provider-assigned unique ID for this managed resource.
idstringThe provider-assigned unique ID for this managed resource.
idStringThe provider-assigned unique ID for this managed resource.
idstringThe provider-assigned unique ID for this managed resource.
idstrThe provider-assigned unique ID for this managed resource.
idStringThe provider-assigned unique ID for this managed resource.
Look up Existing BucketLogging Resource Anchor
Get an existing BucketLogging resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
- TypeScript
- Python
- Go
- C#
- Java
- YAML
- HCL PREVIEW
public static get(name: string, id: Input<ID>, state?: BucketLoggingState, opts?: CustomResourceOptions): BucketLogging
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
bucket: Optional[str] = None,
expected_bucket_owner: Optional[str] = None,
region: Optional[str] = None,
target_bucket: Optional[str] = None,
target_grants: Optional[Sequence[BucketLoggingTargetGrantArgs]] = None,
target_object_key_format: Optional[BucketLoggingTargetObjectKeyFormatArgs] = None,
target_prefix: Optional[str] = None) -> BucketLogging
func GetBucketLogging(ctx *Context, name string, id IDInput, state *BucketLoggingState, opts ...ResourceOption) (*BucketLogging, error)
public static BucketLogging Get(string name, Input<string> id, BucketLoggingState? state, CustomResourceOptions? opts = null)
public static BucketLogging get(String name, Output<String> id, BucketLoggingState state, CustomResourceOptions options)
resources: _: type: aws:s3:BucketLogging get: id: ${id}
import {
to = aws_s3_bucketlogging.example
id = "${id}"
}
nameThis property is required.The unique name of the resulting resource.idThis property is required.The unique provider ID of the resource to lookup.stateAny extra arguments used during the lookup.optsA bag of options that control this resource's behavior.
resource_nameThis property is required.The unique name of the resulting resource.idThis property is required.The unique provider ID of the resource to lookup.
The following state arguments are supported:
BucketChanges to this property will trigger replacement.stringName of the bucket.ExpectedBucketOwnerstringAccount ID of the expected bucket owner.
Deprecated: expected_bucket_owner is deprecated. It will be removed in a future verion of the provider.
RegionstringRegion where this resource will be managed. Defaults to the Region set in the provider configuration.TargetBucketstringName of the bucket where you want Amazon S3 to store server access logs.TargetGrantsList
BucketChanges to this property will trigger replacement.stringName of the bucket.ExpectedBucketOwnerstringAccount ID of the expected bucket owner.
Deprecated: expected_bucket_owner is deprecated. It will be removed in a future verion of the provider.
RegionstringRegion where this resource will be managed. Defaults to the Region set in the provider configuration.TargetBucketstringName of the bucket where you want Amazon S3 to store server access logs.TargetGrants[]BucketLoggingTargetGrantArgsSet of configuration blocks with information for granting permissions. See below.TargetObjectKeyFormatBucketLoggingTargetObjectKeyFormatArgsAmazon S3 key format for log objects. See below.TargetPrefixstringPrefix for all log object keys.
bucketChanges to this property will trigger replacement.stringName of the bucket.expected_bucket_ownerstringAccount ID of the expected bucket owner.
Deprecated: expected_bucket_owner is deprecated. It will be removed in a future verion of the provider.
regionstringRegion where this resource will be managed. Defaults to the Region set in the provider configuration.target_bucketstringName of the bucket where you want Amazon S3 to store server access logs.target_grantslist(object)Set of configuration blocks with information for granting permissions. See below.target_object_key_formatobjectAmazon S3 key format for log objects. See below.target_prefixstringPrefix for all log object keys.
bucketChanges to this property will trigger replacement.StringName of the bucket.expectedBucketOwnerStringAccount ID of the expected bucket owner.
Deprecated: expected_bucket_owner is deprecated. It will be removed in a future verion of the provider.
regionStringRegion where this resource will be managed. Defaults to the Region set in the provider configuration.targetBucketStringName of the bucket where you want Amazon S3 to store server access logs.targetGrantsList
bucketChanges to this property will trigger replacement.stringName of the bucket.expectedBucketOwnerstringAccount ID of the expected bucket owner.
Deprecated: expected_bucket_owner is deprecated. It will be removed in a future verion of the provider.
regionstringRegion where this resource will be managed. Defaults to the Region set in the provider configuration.targetBucketstringName of the bucket where you want Amazon S3 to store server access logs.targetGrantsBucketLoggingTargetGrant[]Set of configuration blocks with information for granting permissions. See below.targetObjectKeyFormatBucketLoggingTargetObjectKeyFormatAmazon S3 key format for log objects. See below.targetPrefixstringPrefix for all log object keys.
bucketChanges to this property will trigger replacement.strName of the bucket.expected_bucket_ownerstrAccount ID of the expected bucket owner.
Deprecated: expected_bucket_owner is deprecated. It will be removed in a future verion of the provider.
regionstrRegion where this resource will be managed. Defaults to the Region set in the provider configuration.target_bucketstrName of the bucket where you want Amazon S3 to store server access logs.target_grantsSequence[BucketLoggingTargetGrantArgs]Set of configuration blocks with information for granting permissions. See below.target_object_key_formatBucketLoggingTargetObjectKeyFormatArgsAmazon S3 key format for log objects. See below.target_prefixstrPrefix for all log object keys.
bucketChanges to this property will trigger replacement.StringName of the bucket.expectedBucketOwnerStringAccount ID of the expected bucket owner.
Deprecated: expected_bucket_owner is deprecated. It will be removed in a future verion of the provider.
regionStringRegion where this resource will be managed. Defaults to the Region set in the provider configuration.targetBucketStringName of the bucket where you want Amazon S3 to store server access logs.targetGrantsList
Supporting Types Anchor
BucketLoggingTargetGrant , BucketLoggingTargetGrantArgs Anchor
GranteeThis property is required.BucketLoggingTargetGrantGranteeConfiguration block for the person being granted permissions. See below.PermissionThis property is required.stringLogging permissions assigned to the grantee for the bucket. Valid values: FULL_CONTROL, READ, WRITE.
GranteeThis property is required.BucketLoggingTargetGrantGranteeConfiguration block for the person being granted permissions. See below.PermissionThis property is required.stringLogging permissions assigned to the grantee for the bucket. Valid values: FULL_CONTROL, READ, WRITE.
granteeThis property is required.objectConfiguration block for the person being granted permissions. See below.permissionThis property is required.stringLogging permissions assigned to the grantee for the bucket. Valid values: FULL_CONTROL, READ, WRITE.
granteeThis property is required.BucketLoggingTargetGrantGranteeConfiguration block for the person being granted permissions. See below.permissionThis property is required.StringLogging permissions assigned to the grantee for the bucket. Valid values: FULL_CONTROL, READ, WRITE.
granteeThis property is required.BucketLoggingTargetGrantGranteeConfiguration block for the person being granted permissions. See below.permissionThis property is required.stringLogging permissions assigned to the grantee for the bucket. Valid values: FULL_CONTROL, READ, WRITE.
granteeThis property is required.BucketLoggingTargetGrantGranteeConfiguration block for the person being granted permissions. See below.permissionThis property is required.strLogging permissions assigned to the grantee for the bucket. Valid values: FULL_CONTROL, READ, WRITE.
granteeThis property is required.Property MapConfiguration block for the person being granted permissions. See below.permissionThis property is required.StringLogging permissions assigned to the grantee for the bucket. Valid values: FULL_CONTROL, READ, WRITE.
BucketLoggingTargetGrantGrantee , BucketLoggingTargetGrantGranteeArgs Anchor
TypeThis property is required.stringType of grantee. Valid values: CanonicalUser, AmazonCustomerByEmail, Group.DisplayNamestring
Deprecated: display_name is deprecated. This attribute is no longer returned by AWS and will be removed in a future major version.
EmailAddressstringEmail address of the grantee. See Regions and Endpoints for supported AWS regions where this argument can be specified.IdstringCanonical user ID of the grantee.UristringURI of the grantee group.
TypeThis property is required.stringType of grantee. Valid values: CanonicalUser, AmazonCustomerByEmail, Group.DisplayNamestring
Deprecated: display_name is deprecated. This attribute is no longer returned by AWS and will be removed in a future major version.
EmailAddressstringEmail address of the grantee. See Regions and Endpoints for supported AWS regions where this argument can be specified.IdstringCanonical user ID of the grantee.UristringURI of the grantee group.
typeThis property is required.stringType of grantee. Valid values: CanonicalUser, AmazonCustomerByEmail, Group.display_namestring
Deprecated: display_name is deprecated. This attribute is no longer returned by AWS and will be removed in a future major version.
email_addressstringEmail address of the grantee. See Regions and Endpoints for supported AWS regions where this argument can be specified.idstringCanonical user ID of the grantee.uristringURI of the grantee group.
typeThis property is required.StringType of grantee. Valid values: CanonicalUser, AmazonCustomerByEmail, Group.displayNameString
Deprecated: display_name is deprecated. This attribute is no longer returned by AWS and will be removed in a future major version.
emailAddressStringEmail address of the grantee. See Regions and Endpoints for supported AWS regions where this argument can be specified.idStringCanonical user ID of the grantee.uriStringURI of the grantee group.
typeThis property is required.stringType of grantee. Valid values: CanonicalUser, AmazonCustomerByEmail, Group.displayNamestring
Deprecated: display_name is deprecated. This attribute is no longer returned by AWS and will be removed in a future major version.
emailAddressstringEmail address of the grantee. See Regions and Endpoints for supported AWS regions where this argument can be specified.idstringCanonical user ID of the grantee.uristringURI of the grantee group.
typeThis property is required.strType of grantee. Valid values: CanonicalUser, AmazonCustomerByEmail, Group.display_namestr
Deprecated: display_name is deprecated. This attribute is no longer returned by AWS and will be removed in a future major version.
email_addressstrEmail address of the grantee. See Regions and Endpoints for supported AWS regions where this argument can be specified.idstrCanonical user ID of the grantee.uristrURI of the grantee group.
typeThis property is required.StringType of grantee. Valid values: CanonicalUser, AmazonCustomerByEmail, Group.displayNameString
Deprecated: display_name is deprecated. This attribute is no longer returned by AWS and will be removed in a future major version.
emailAddressStringEmail address of the grantee. See Regions and Endpoints for supported AWS regions where this argument can be specified.idStringCanonical user ID of the grantee.uriStringURI of the grantee group.
BucketLoggingTargetObjectKeyFormat , BucketLoggingTargetObjectKeyFormatArgs Anchor
PartitionedPrefixBucketLoggingTargetObjectKeyFormatPartitionedPrefixPartitioned S3 key for log objects, in the form [targetPrefix][SourceAccountId]/[SourceRegion]/[SourceBucket]/[YYYY]/[MM]/[DD]/[YYYY]-[MM]-[DD]-[hh]-[mm]-[ss]-[UniqueString]. Conflicts with simplePrefix. See below.SimplePrefixBucketLoggingTargetObjectKeyFormatSimplePrefixUse the simple format for S3 keys for log objects, in the form [targetPrefix][YYYY]-[MM]-[DD]-[hh]-[mm]-[ss]-[UniqueString]. To use, set simplePrefix {}. Conflicts with partitionedPrefix.
PartitionedPrefixBucketLoggingTargetObjectKeyFormatPartitionedPrefixPartitioned S3 key for log objects, in the form [targetPrefix][SourceAccountId]/[SourceRegion]/[SourceBucket]/[YYYY]/[MM]/[DD]/[YYYY]-[MM]-[DD]-[hh]-[mm]-[ss]-[UniqueString]. Conflicts with simplePrefix. See below.SimplePrefixBucketLoggingTargetObjectKeyFormatSimplePrefixUse the simple format for S3 keys for log objects, in the form [targetPrefix][YYYY]-[MM]-[DD]-[hh]-[mm]-[ss]-[UniqueString]. To use, set simplePrefix {}. Conflicts with partitionedPrefix.
partitioned_prefixobjectPartitioned S3 key for log objects, in the form [targetPrefix][SourceAccountId]/[SourceRegion]/[SourceBucket]/[YYYY]/[MM]/[DD]/[YYYY]-[MM]-[DD]-[hh]-[mm]-[ss]-[UniqueString]. Conflicts with simplePrefix. See below.simple_prefixobjectUse the simple format for S3 keys for log objects, in the form [targetPrefix][YYYY]-[MM]-[DD]-[hh]-[mm]-[ss]-[UniqueString]. To use, set simplePrefix {}. Conflicts with partitionedPrefix.
partitionedPrefixBucketLoggingTargetObjectKeyFormatPartitionedPrefixPartitioned S3 key for log objects, in the form [targetPrefix][SourceAccountId]/[SourceRegion]/[SourceBucket]/[YYYY]/[MM]/[DD]/[YYYY]-[MM]-[DD]-[hh]-[mm]-[ss]-[UniqueString]. Conflicts with simplePrefix. See below.simplePrefixBucketLoggingTargetObjectKeyFormatSimplePrefixUse the simple format for S3 keys for log objects, in the form [targetPrefix][YYYY]-[MM]-[DD]-[hh]-[mm]-[ss]-[UniqueString]. To use, set simplePrefix {}. Conflicts with partitionedPrefix.
partitionedPrefixBucketLoggingTargetObjectKeyFormatPartitionedPrefixPartitioned S3 key for log objects, in the form [targetPrefix][SourceAccountId]/[SourceRegion]/[SourceBucket]/[YYYY]/[MM]/[DD]/[YYYY]-[MM]-[DD]-[hh]-[mm]-[ss]-[UniqueString]. Conflicts with simplePrefix. See below.simplePrefixBucketLoggingTargetObjectKeyFormatSimplePrefixUse the simple format for S3 keys for log objects, in the form [targetPrefix][YYYY]-[MM]-[DD]-[hh]-[mm]-[ss]-[UniqueString]. To use, set simplePrefix {}. Conflicts with partitionedPrefix.
partitioned_prefixBucketLoggingTargetObjectKeyFormatPartitionedPrefixPartitioned S3 key for log objects, in the form [targetPrefix][SourceAccountId]/[SourceRegion]/[SourceBucket]/[YYYY]/[MM]/[DD]/[YYYY]-[MM]-[DD]-[hh]-[mm]-[ss]-[UniqueString]. Conflicts with simplePrefix. See below.simple_prefixBucketLoggingTargetObjectKeyFormatSimplePrefixUse the simple format for S3 keys for log objects, in the form [targetPrefix][YYYY]-[MM]-[DD]-[hh]-[mm]-[ss]-[UniqueString]. To use, set simplePrefix {}. Conflicts with partitionedPrefix.
partitionedPrefixProperty MapPartitioned S3 key for log objects, in the form [targetPrefix][SourceAccountId]/[SourceRegion]/[SourceBucket]/[YYYY]/[MM]/[DD]/[YYYY]-[MM]-[DD]-[hh]-[mm]-[ss]-[UniqueString]. Conflicts with simplePrefix. See below.simplePrefixProperty MapUse the simple format for S3 keys for log objects, in the form [targetPrefix][YYYY]-[MM]-[DD]-[hh]-[mm]-[ss]-[UniqueString]. To use, set simplePrefix {}. Conflicts with partitionedPrefix.
BucketLoggingTargetObjectKeyFormatPartitionedPrefix , BucketLoggingTargetObjectKeyFormatPartitionedPrefixArgs Anchor
PartitionDateSourceThis property is required.stringSpecifies the partition date source for the partitioned prefix. Valid values: EventTime, DeliveryTime.
PartitionDateSourceThis property is required.stringSpecifies the partition date source for the partitioned prefix. Valid values: EventTime, DeliveryTime.
partition_date_sourceThis property is required.stringSpecifies the partition date source for the partitioned prefix. Valid values: EventTime, DeliveryTime.
partitionDateSourceThis property is required.StringSpecifies the partition date source for the partitioned prefix. Valid values: EventTime, DeliveryTime.
partitionDateSourceThis property is required.stringSpecifies the partition date source for the partitioned prefix. Valid values: EventTime, DeliveryTime.
partition_date_sourceThis property is required.strSpecifies the partition date source for the partitioned prefix. Valid values: EventTime, DeliveryTime.
partitionDateSourceThis property is required.StringSpecifies the partition date source for the partitioned prefix. Valid values: EventTime, DeliveryTime.
Import Anchor
Identity Schema Anchor
Required Anchor
bucket(String) S3 bucket name.
Optional Anchor
accountId(String) AWS Account where this resource is managed.region(String) Region where this resource is managed.
If the owner (account ID) of the source bucket differs from the account used to configure the AWS Provider, import using the bucket and expectedBucketOwner separated by a comma (,):
Using pulumi import to import S3 bucket logging using the bucket or using the bucket and expectedBucketOwner separated by a comma (,). For example:
If the owner (account ID) of the source bucket is the same account used to configure the AWS Provider, import using the bucket:
$ pulumi import aws:s3/bucketLogging:BucketLogging example bucket-name
Copy
$ pulumi import aws:s3/bucketLogging:BucketLogging example bucket-name,123456789012
Copy
To learn more about importing existing cloud resources, see Importing resources.
Package Details Anchor
Viewing docs for AWS v7.32.0
published on Friday, May 29, 2026 by Pulumi
v7.32.0 (7.x, latest)v6.83.1 (6.x)v5.43.0 (5.x)
On this page
On this page
- Copy Page
[Scroll to top](/content/registry/packages/aws/api-docs/s3/bucketlogging/# "Scroll to top"/index.html)