-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: pass ScheduleOffset config property and remove Timezone (#333)
This PR: - removes the useless Timezone property (which was not passed through the ScheduleConfig anyway) - fixes the code to pass the `offset` property (which maps to `ScheduleOffset` in the L1 CFN resource) Fixes #345
- Loading branch information
Showing
3 changed files
with
145 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
/* | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import { Duration, Stack } from 'aws-cdk-lib'; | ||
import { Template } from 'aws-cdk-lib/assertions'; | ||
import { Schedule } from 'aws-cdk-lib/aws-events'; | ||
import { Key } from 'aws-cdk-lib/aws-kms'; | ||
import { Bucket } from 'aws-cdk-lib/aws-s3'; | ||
import { | ||
S3Source, | ||
S3Destination, | ||
Mapping, | ||
OnScheduleFlow, | ||
DataPullMode, | ||
} from '../../../src'; | ||
|
||
describe('OnScheduleFlow', () => { | ||
test('', () => { | ||
const stack = new Stack(undefined, 'TestStack'); | ||
|
||
const bucket = new Bucket(stack, 'TestBucket'); | ||
|
||
const source = new S3Source({ | ||
bucket: bucket, | ||
prefix: 'account', | ||
}); | ||
|
||
const destination = new S3Destination({ | ||
location: { bucket, prefix: 'new-account' }, | ||
}); | ||
|
||
|
||
new OnScheduleFlow(stack, 'OnScheduleFlow', { | ||
source, | ||
destination, | ||
key: new Key(stack, 'TestKey'), | ||
mappings: [Mapping.mapAll()], | ||
schedule: Schedule.rate(Duration.days(1)), | ||
pullConfig: { | ||
mode: DataPullMode.INCREMENTAL, | ||
}, | ||
}); | ||
|
||
const template = Template.fromStack(stack); | ||
|
||
template.hasResourceProperties('AWS::AppFlow::Flow', { | ||
DestinationFlowConfigList: [ | ||
{ | ||
ConnectorType: 'S3', | ||
DestinationConnectorProperties: { | ||
S3: { | ||
BucketName: { | ||
Ref: 'TestBucket560B80BC', | ||
}, | ||
BucketPrefix: 'new-account', | ||
}, | ||
}, | ||
}, | ||
], | ||
FlowName: 'OnScheduleFlow', | ||
SourceFlowConfig: { | ||
ConnectorType: 'S3', | ||
SourceConnectorProperties: { | ||
S3: { | ||
BucketName: { | ||
Ref: 'TestBucket560B80BC', | ||
}, | ||
BucketPrefix: 'account', | ||
}, | ||
}, | ||
}, | ||
Tasks: [ | ||
{ | ||
ConnectorOperator: { | ||
S3: 'NO_OP', | ||
}, | ||
SourceFields: [], | ||
TaskProperties: [ | ||
{ | ||
Key: 'EXCLUDE_SOURCE_FIELDS_LIST', | ||
Value: '[]', | ||
}, | ||
], | ||
TaskType: 'Map_all', | ||
}, | ||
], | ||
TriggerConfig: { | ||
TriggerType: 'Scheduled', | ||
TriggerProperties: { | ||
DataPullMode: 'Incremental', | ||
}, | ||
}, | ||
KMSArn: { | ||
'Fn::GetAtt': [ | ||
'TestKey4CACAF33', | ||
'Arn', | ||
], | ||
}, | ||
}); | ||
}); | ||
|
||
test('it passes offset', () => { | ||
const stack = new Stack(undefined, 'TestStack'); | ||
|
||
const bucket = new Bucket(stack, 'TestBucket'); | ||
|
||
const source = new S3Source({ | ||
bucket: bucket, | ||
prefix: 'account', | ||
}); | ||
|
||
const destination = new S3Destination({ | ||
location: { bucket, prefix: 'new-account' }, | ||
}); | ||
|
||
|
||
new OnScheduleFlow(stack, 'OnScheduleFlow', { | ||
source, | ||
destination, | ||
mappings: [Mapping.mapAll()], | ||
schedule: Schedule.rate(Duration.days(1)), | ||
pullConfig: { | ||
mode: DataPullMode.INCREMENTAL, | ||
}, | ||
scheduleProperties: { | ||
offset: Duration.hours(1), | ||
}, | ||
}); | ||
|
||
const template = Template.fromStack(stack); | ||
|
||
template.hasResourceProperties('AWS::AppFlow::Flow', { | ||
FlowName: 'OnScheduleFlow', | ||
TriggerConfig: { | ||
TriggerType: 'Scheduled', | ||
TriggerProperties: { | ||
DataPullMode: 'Incremental', | ||
ScheduleOffset: 3600, | ||
}, | ||
}, | ||
}); | ||
}); | ||
}); |