Bucket Logging V2Args
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
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.s3.BucketV2("example", {bucket: "my-tf-example-bucket"});
const exampleBucketAclV2 = new aws.s3.BucketAclV2("example", {
bucket: example.id,
acl: "private",
});
const logBucket = new aws.s3.BucketV2("log_bucket", {bucket: "my-tf-log-bucket"});
const logBucketAcl = new aws.s3.BucketAclV2("log_bucket_acl", {
bucket: logBucket.id,
acl: "log-delivery-write",
});
const exampleBucketLoggingV2 = new aws.s3.BucketLoggingV2("example", {
bucket: example.id,
targetBucket: logBucket.id,
targetPrefix: "log/",
});
import pulumi
import pulumi_aws as aws
example = aws.s3.BucketV2("example", bucket="my-tf-example-bucket")
example_bucket_acl_v2 = aws.s3.BucketAclV2("example",
bucket=example.id,
acl="private")
log_bucket = aws.s3.BucketV2("log_bucket", bucket="my-tf-log-bucket")
log_bucket_acl = aws.s3.BucketAclV2("log_bucket_acl",
bucket=log_bucket.id,
acl="log-delivery-write")
example_bucket_logging_v2 = aws.s3.BucketLoggingV2("example",
bucket=example.id,
target_bucket=log_bucket.id,
target_prefix="log/")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.S3.BucketV2("example", new()
{
Bucket = "my-tf-example-bucket",
});
var exampleBucketAclV2 = new Aws.S3.BucketAclV2("example", new()
{
Bucket = example.Id,
Acl = "private",
});
var logBucket = new Aws.S3.BucketV2("log_bucket", new()
{
Bucket = "my-tf-log-bucket",
});
var logBucketAcl = new Aws.S3.BucketAclV2("log_bucket_acl", new()
{
Bucket = logBucket.Id,
Acl = "log-delivery-write",
});
var exampleBucketLoggingV2 = new Aws.S3.BucketLoggingV2("example", new()
{
Bucket = example.Id,
TargetBucket = logBucket.Id,
TargetPrefix = "log/",
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := s3.NewBucketV2(ctx, "example", &s3.BucketV2Args{
Bucket: pulumi.String("my-tf-example-bucket"),
})
if err != nil {
return err
}
_, err = s3.NewBucketAclV2(ctx, "example", &s3.BucketAclV2Args{
Bucket: example.ID(),
Acl: pulumi.String("private"),
})
if err != nil {
return err
}
logBucket, err := s3.NewBucketV2(ctx, "log_bucket", &s3.BucketV2Args{
Bucket: pulumi.String("my-tf-log-bucket"),
})
if err != nil {
return err
}
_, err = s3.NewBucketAclV2(ctx, "log_bucket_acl", &s3.BucketAclV2Args{
Bucket: logBucket.ID(),
Acl: pulumi.String("log-delivery-write"),
})
if err != nil {
return err
}
_, err = s3.NewBucketLoggingV2(ctx, "example", &s3.BucketLoggingV2Args{
Bucket: example.ID(),
TargetBucket: logBucket.ID(),
TargetPrefix: pulumi.String("log/"),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.s3.BucketV2;
import com.pulumi.aws.s3.BucketV2Args;
import com.pulumi.aws.s3.BucketAclV2;
import com.pulumi.aws.s3.BucketAclV2Args;
import com.pulumi.aws.s3.BucketLoggingV2;
import com.pulumi.aws.s3.BucketLoggingV2Args;
import java.util.List;
import java.util.ArrayList;
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 BucketV2("example", BucketV2Args.builder()
.bucket("my-tf-example-bucket")
.build());
var exampleBucketAclV2 = new BucketAclV2("exampleBucketAclV2", BucketAclV2Args.builder()
.bucket(example.id())
.acl("private")
.build());
var logBucket = new BucketV2("logBucket", BucketV2Args.builder()
.bucket("my-tf-log-bucket")
.build());
var logBucketAcl = new BucketAclV2("logBucketAcl", BucketAclV2Args.builder()
.bucket(logBucket.id())
.acl("log-delivery-write")
.build());
var exampleBucketLoggingV2 = new BucketLoggingV2("exampleBucketLoggingV2", BucketLoggingV2Args.builder()
.bucket(example.id())
.targetBucket(logBucket.id())
.targetPrefix("log/")
.build());
}
}
resources:
example:
type: aws:s3:BucketV2
properties:
bucket: my-tf-example-bucket
exampleBucketAclV2:
type: aws:s3:BucketAclV2
name: example
properties:
bucket: ${example.id}
acl: private
logBucket:
type: aws:s3:BucketV2
name: log_bucket
properties:
bucket: my-tf-log-bucket
logBucketAcl:
type: aws:s3:BucketAclV2
name: log_bucket_acl
properties:
bucket: ${logBucket.id}
acl: log-delivery-write
exampleBucketLoggingV2:
type: aws:s3:BucketLoggingV2
name: example
properties:
bucket: ${example.id}
targetBucket: ${logBucket.id}
targetPrefix: log/
Import
If the owner (account ID) of the source bucket differs from the account used to configure the AWS Provider, import using the bucket
and expected_bucket_owner
separated by a comma (,
): Using pulumi import
to import S3 bucket logging using the bucket
or using the bucket
and expected_bucket_owner
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/bucketLoggingV2:BucketLoggingV2 example bucket-name
If the owner (account ID) of the source bucket differs from the account used to configure the AWS Provider, import using the bucket
and expected_bucket_owner
separated by a comma (,
):
$ pulumi import aws:s3/bucketLoggingV2:BucketLoggingV2 example bucket-name,123456789012
Constructors
Properties
Account ID of the expected bucket owner.
Name of the bucket where you want Amazon S3 to store server access logs.
Set of configuration blocks with information for granting permissions. See below.
Amazon S3 key format for log objects. See below.
Prefix for all log object keys.