Skip to content

Commit 2bbe762

Browse files
authored
feat(kinesisfirehose): support custom time zone settings for S3 destination (#34738)
### Issue # (if applicable) Closes #34737. ### Reason for this change Amazon Data Firehose supports to configure the time zone of timestamps in S3 object prefix. For details, see https://docs.aws.amazon.com/firehose/latest/dev/s3-prefixes.html#timestamp-namespace ### Description of changes Added the `timeZone` prop to `S3BucketProps` interface to set `ExtendedS3Destination.CustomTimeZone`. Note: Not in `CommonProps` since only `ExtendedS3DestinationConfiguration` supports time zone. ### Describe any new or updated permissions being added N/A ### Description of how you validated changes Unit test and integ test. I've confirmed setting timeZone reflects to Firehose's console. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 2e0e536 commit 2bbe762

File tree

5 files changed

+32
-1
lines changed

5 files changed

+32
-1
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-kinesisfirehose/test/integ.s3-bucket.lit.js.snapshot/aws-cdk-firehose-delivery-stream-s3-all-properties.template.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@
579579
}
580580
},
581581
"CompressionFormat": "GZIP",
582+
"CustomTimeZone": "Asia/Tokyo",
582583
"EncryptionConfiguration": {
583584
"KMSEncryptionConfig": {
584585
"AWSKMSKeyARN": {

packages/@aws-cdk-testing/framework-integ/test/aws-kinesisfirehose/test/integ.s3-bucket.lit.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const deliveryStream = new firehose.DeliveryStream(stack, 'DeliveryStream', {
5656
dataOutputPrefix: 'regularPrefix',
5757
errorOutputPrefix: 'errorPrefix',
5858
fileExtension: '.log.gz',
59+
timeZone: cdk.TimeZone.ASIA_TOKYO,
5960
bufferingInterval: cdk.Duration.seconds(60),
6061
bufferingSize: cdk.Size.mebibytes(1),
6162
encryptionKey: key,

packages/aws-cdk-lib/aws-kinesisfirehose/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,13 @@ will be used for files successfully delivered to S3. `errorOutputPrefix` will be
102102
failed records before writing them to S3.
103103

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

packages/aws-cdk-lib/aws-kinesisfirehose/lib/s3-bucket.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { DestinationBindOptions, DestinationConfig, IDestination } from './desti
44
import * as iam from '../../aws-iam';
55
import * as s3 from '../../aws-s3';
66
import { createBackupConfig, createBufferingHints, createEncryptionConfig, createLoggingOptions, createProcessingConfig } from './private/helpers';
7-
import { Token, UnscopedValidationError, ValidationError } from '../../core';
7+
import { TimeZone, Token, UnscopedValidationError, ValidationError } from '../../core';
88

99
/**
1010
* Props for defining an S3 destination of an Amazon Data Firehose delivery stream.
@@ -20,6 +20,15 @@ export interface S3BucketProps extends CommonDestinationS3Props, CommonDestinati
2020
* @default - The default file extension appended by Data Format Conversion or S3 compression features
2121
*/
2222
readonly fileExtension?: string;
23+
24+
/**
25+
* The time zone you prefer.
26+
*
27+
* @see https://docs.aws.amazon.com/firehose/latest/dev/s3-prefixes.html#timestamp-namespace
28+
*
29+
* @default - UTC
30+
*/
31+
readonly timeZone?: TimeZone;
2332
}
2433

2534
/**
@@ -71,6 +80,7 @@ export class S3Bucket implements IDestination {
7180
errorOutputPrefix: this.props.errorOutputPrefix,
7281
prefix: this.props.dataOutputPrefix,
7382
fileExtension: this.props.fileExtension,
83+
customTimeZone: this.props.timeZone?.timezoneName,
7484
},
7585
dependables: [bucketGrant, ...(loggingDependables ?? []), ...(backupDependables ?? [])],
7686
};

packages/aws-cdk-lib/aws-kinesisfirehose/test/s3-bucket.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,4 +658,20 @@ describe('S3 destination', () => {
658658
}).toThrow("fileExtension can contain allowed characters: 0-9a-z!-_.*'()");
659659
});
660660
});
661+
662+
it('sets customTimeZone', () => {
663+
const destination = new firehose.S3Bucket(bucket, {
664+
role: destinationRole,
665+
timeZone: cdk.TimeZone.ASIA_TOKYO,
666+
});
667+
new firehose.DeliveryStream(stack, 'DeliveryStream', {
668+
destination: destination,
669+
});
670+
671+
Template.fromStack(stack).hasResourceProperties('AWS::KinesisFirehose::DeliveryStream', {
672+
ExtendedS3DestinationConfiguration: {
673+
CustomTimeZone: 'Asia/Tokyo',
674+
},
675+
});
676+
});
661677
});

0 commit comments

Comments
 (0)