Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@
}
},
"CompressionFormat": "GZIP",
"CustomTimeZone": "Asia/Tokyo",
"EncryptionConfiguration": {
"KMSEncryptionConfig": {
"AWSKMSKeyARN": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const deliveryStream = new firehose.DeliveryStream(stack, 'DeliveryStream', {
dataOutputPrefix: 'regularPrefix',
errorOutputPrefix: 'errorPrefix',
fileExtension: '.log.gz',
timeZone: cdk.TimeZone.ASIA_TOKYO,
bufferingInterval: cdk.Duration.seconds(60),
bufferingSize: cdk.Size.mebibytes(1),
encryptionKey: key,
Expand Down
3 changes: 3 additions & 0 deletions packages/aws-cdk-lib/aws-kinesisfirehose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,13 @@ will be used for files successfully delivered to S3. `errorOutputPrefix` will be
failed records before writing them to S3.

```ts
import { TimeZone } from 'aws-cdk-lib';
declare const bucket: s3.Bucket;
const s3Destination = new firehose.S3Bucket(bucket, {
dataOutputPrefix: 'myFirehose/DeliveredYear=!{timestamp:yyyy}/anyMonth/rand=!{firehose:random-string}',
errorOutputPrefix: 'myFirehoseFailures/!{firehose:error-output-type}/!{timestamp:yyyy}/anyMonth/!{timestamp:dd}',
// The time zone of timestamps (default UTC)
timeZone: TimeZone.ASIA_TOKYO,
});
```

Expand Down
12 changes: 11 additions & 1 deletion packages/aws-cdk-lib/aws-kinesisfirehose/lib/s3-bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DestinationBindOptions, DestinationConfig, IDestination } from './desti
import * as iam from '../../aws-iam';
import * as s3 from '../../aws-s3';
import { createBackupConfig, createBufferingHints, createEncryptionConfig, createLoggingOptions, createProcessingConfig } from './private/helpers';
import { Token, UnscopedValidationError, ValidationError } from '../../core';
import { TimeZone, Token, UnscopedValidationError, ValidationError } from '../../core';

/**
* Props for defining an S3 destination of an Amazon Data Firehose delivery stream.
Expand All @@ -20,6 +20,15 @@ export interface S3BucketProps extends CommonDestinationS3Props, CommonDestinati
* @default - The default file extension appended by Data Format Conversion or S3 compression features
*/
readonly fileExtension?: string;

/**
* The time zone you prefer.
*
* @see https://docs.aws.amazon.com/firehose/latest/dev/s3-prefixes.html#timestamp-namespace
*
* @default - UTC
*/
readonly timeZone?: TimeZone;
}

/**
Expand Down Expand Up @@ -71,6 +80,7 @@ export class S3Bucket implements IDestination {
errorOutputPrefix: this.props.errorOutputPrefix,
prefix: this.props.dataOutputPrefix,
fileExtension: this.props.fileExtension,
customTimeZone: this.props.timeZone?.timezoneName,
},
dependables: [bucketGrant, ...(loggingDependables ?? []), ...(backupDependables ?? [])],
};
Expand Down
16 changes: 16 additions & 0 deletions packages/aws-cdk-lib/aws-kinesisfirehose/test/s3-bucket.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -658,4 +658,20 @@ describe('S3 destination', () => {
}).toThrow("fileExtension can contain allowed characters: 0-9a-z!-_.*'()");
});
});

it('sets customTimeZone', () => {
const destination = new firehose.S3Bucket(bucket, {
role: destinationRole,
timeZone: cdk.TimeZone.ASIA_TOKYO,
});
new firehose.DeliveryStream(stack, 'DeliveryStream', {
destination: destination,
});

Template.fromStack(stack).hasResourceProperties('AWS::KinesisFirehose::DeliveryStream', {
ExtendedS3DestinationConfiguration: {
CustomTimeZone: 'Asia/Tokyo',
},
});
});
});
Loading