# TargetObjectKeyFormat

The key format for the log object.

Obtainable from: TargetObjectKeyFormat.partitionedPrefix, TargetObjectKeyFormat.simplePrefix

- Source: [`aws-s3/lib/bucket.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-s3/lib/bucket.ts#L1574)
- Type last changed: v2.124.0 · 26 Jan 2024

## Example

TypeScript:

```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:

```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:

```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();
```

C# / .NET:

```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()
});
```

Golang:

```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

TypeScript:

```ts
new TargetObjectKeyFormat()
```

Python:

```python
TargetObjectKeyFormat()
```

Java:

```java
new TargetObjectKeyFormat()
```

C# / .NET:

```csharp
new TargetObjectKeyFormat()
```

Golang:

```go
NewTargetObjectKeyFormat()
```

## Methods

- `partitionedPrefix(dateSource?: PartitionDateSource): TargetObjectKeyFormat // chainable` (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` (static) — Use the simple prefix for log objects.

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