Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Typescript conversion of
GlueTransformStage
(#152)
* add glue transform stage & simple test case * pr feedback * run build & prettier
- Loading branch information
1 parent
6b5beb3
commit 041ad13
Showing
5 changed files
with
390 additions
and
2 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import * as sfn from 'aws-cdk-lib/aws-stepfunctions'; | ||
import * as tasks from 'aws-cdk-lib/aws-stepfunctions-tasks'; | ||
import { Construct } from 'constructs'; | ||
import { StateMachineStage, StateMachineStageProps } from '../pipelines/stage'; | ||
|
||
export interface GlueTransformStageProps extends StateMachineStageProps { | ||
readonly jobName: string; | ||
readonly jobArgs?: { [key: string]: any }; | ||
readonly crawlerName: string; | ||
} | ||
|
||
export class GlueTransformStage extends StateMachineStage { | ||
private readonly jobName: string; | ||
private readonly jobArgs?: { [key: string]: any }; | ||
private readonly crawlerName: string; | ||
|
||
constructor(scope: Construct, id: string, props: GlueTransformStageProps) { | ||
super(scope, id, props); | ||
|
||
this.jobName = props.jobName; | ||
this.jobArgs = props.jobArgs; | ||
this.crawlerName = props.crawlerName; | ||
} | ||
|
||
protected createStateMachineSteps(): sfn.IChainable { | ||
const startJobRun = new tasks.GlueStartJobRun(this, 'Start Job Run', { | ||
glueJobName: this.jobName, | ||
integrationPattern: sfn.IntegrationPattern.RUN_JOB, | ||
arguments: this.jobArgs ? sfn.TaskInput.fromObject(this.jobArgs) : undefined, | ||
resultPath: sfn.JsonPath.DISCARD, | ||
}); | ||
|
||
const crawlObject = new sfn.CustomState(this, 'Crawl Object', { | ||
stateJson: { | ||
Type: 'Task', | ||
Resource: 'arn:aws:states:::aws-sdk:glue:startCrawler', | ||
Parameters: { Name: this.crawlerName }, | ||
Catch: [{ ErrorEquals: ['Glue.CrawlerRunningException'], Next: 'Success' }], | ||
}, | ||
}); | ||
|
||
return startJobRun.next(crawlObject.next(new sfn.Succeed(this, 'Success'))); | ||
} | ||
} |
Oops, something went wrong.