Skip to content
v2.278.0

TargetObjectKeyFormat Class ​

The key format for the log object.

Example ​

ts
const accessLogsBucket = new s3.Bucket(this, 'AccessLogsBucket');

const bucket = new s3.Bucket(this, 'MyBucket', {
  serverAccessLogsBucket: accessLogsBucket,
  serverAccessLogsPrefix: 'logs',
  // You can use a simple prefix with `TargetObjectKeyFormat.simplePrefix()`, but it is the same even if you do not specify `targetObjectKeyFormat` property.
  targetObjectKeyFormat: s3.TargetObjectKeyFormat.simplePrefix(),
});
python
access_logs_bucket = s3.Bucket(self, "AccessLogsBucket")

bucket = s3.Bucket(self, "MyBucket",
    server_access_logs_bucket=access_logs_bucket,
    server_access_logs_prefix="logs",
    # You can use a simple prefix with `TargetObjectKeyFormat.simplePrefix()`, but it is the same even if you do not specify `targetObjectKeyFormat` property.
    target_object_key_format=s3.TargetObjectKeyFormat.simple_prefix()
)
java
Bucket accessLogsBucket = new Bucket(this, "AccessLogsBucket");

Bucket bucket = Bucket.Builder.create(this, "MyBucket")
        .serverAccessLogsBucket(accessLogsBucket)
        .serverAccessLogsPrefix("logs")
        // You can use a simple prefix with `TargetObjectKeyFormat.simplePrefix()`, but it is the same even if you do not specify `targetObjectKeyFormat` property.
        .targetObjectKeyFormat(TargetObjectKeyFormat.simplePrefix())
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
var accessLogsBucket = new Bucket(this, "AccessLogsBucket");

var bucket = new Bucket(this, "MyBucket", new BucketProps {
    ServerAccessLogsBucket = accessLogsBucket,
    ServerAccessLogsPrefix = "logs",
    // You can use a simple prefix with `TargetObjectKeyFormat.simplePrefix()`, but it is the same even if you do not specify `targetObjectKeyFormat` property.
    TargetObjectKeyFormat = TargetObjectKeyFormat.SimplePrefix()
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
accessLogsBucket := s3.NewBucket(this, jsii.String("AccessLogsBucket"))

bucket := s3.NewBucket(this, jsii.String("MyBucket"), &BucketProps{
	ServerAccessLogsBucket: accessLogsBucket,
	ServerAccessLogsPrefix: jsii.String("logs"),
	// You can use a simple prefix with `TargetObjectKeyFormat.simplePrefix()`, but it is the same even if you do not specify `targetObjectKeyFormat` property.
	TargetObjectKeyFormat: s3.TargetObjectKeyFormat_SimplePrefix(),
})

Initializer ​

ts
new TargetObjectKeyFormat()
python
TargetObjectKeyFormat()
java
new TargetObjectKeyFormat()
csharp
new TargetObjectKeyFormat()
go
NewTargetObjectKeyFormat()

Methods ​

partitionedPrefix(dateSource?: PartitionDateSource): TargetObjectKeyFormat // chainable@staticmethod def partitioned_prefix(date_source: typing.Optional[PartitionDateSource] = None) -> TargetObjectKeyFormatpublic static TargetObjectKeyFormat partitionedPrefix(PartitionDateSource dateSource)public static TargetObjectKeyFormat PartitionedPrefix(PartitionDateSource? dateSource = null)func PartitionedPrefix(DateSource PartitionDateSource) TargetObjectKeyFormat static #
Use partitioned prefix for log objects. If you do not specify the dateSource argument, the default is EventTime.

The partitioned prefix format as follow: [DestinationPrefix][SourceAccountId]/​[SourceRegion]/​[SourceBucket]/​[YYYY]/​[MM]/​[DD]/​[YYYY]-[MM]-[DD]-[hh]-[mm]-[ss]-[UniqueString]

simplePrefix(): TargetObjectKeyFormat // chainable@staticmethod def simple_prefix() -> TargetObjectKeyFormatpublic static TargetObjectKeyFormat simplePrefix()public static TargetObjectKeyFormat SimplePrefix()func SimplePrefix() TargetObjectKeyFormat static #
Use the simple prefix for log objects.

The simple prefix format as follow: [DestinationPrefix][YYYY]-[MM]-[DD]-[hh]-[mm]-[ss]-[UniqueString]