-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pipes-targets): add SageMaker (#30696)
Add SageMaker pipeline as a Pipes target.
- Loading branch information
Showing
20 changed files
with
34,692 additions
and
5 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
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
66 changes: 66 additions & 0 deletions
66
packages/@aws-cdk/aws-pipes-targets-alpha/lib/sagemaker.ts
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,66 @@ | ||
import { IInputTransformation, IPipe, ITarget, TargetConfig } from '@aws-cdk/aws-pipes-alpha'; | ||
import { IRole } from 'aws-cdk-lib/aws-iam'; | ||
import { IPipeline } from 'aws-cdk-lib/aws-sagemaker'; | ||
|
||
/** | ||
* SageMaker target properties. | ||
*/ | ||
export interface SageMakerTargetParameters { | ||
/** | ||
* The input transformation to apply to the message before sending it to the target. | ||
* | ||
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-pipes-pipe-pipetargetparameters.html#cfn-pipes-pipe-pipetargetparameters-inputtemplate | ||
* @default - none | ||
*/ | ||
readonly inputTransformation?: IInputTransformation; | ||
|
||
/** | ||
* List of parameter names and values for SageMaker Model Building Pipeline execution. | ||
* | ||
* The Name/Value pairs are passed to start execution of the pipeline. | ||
* | ||
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-pipes-pipe-pipetargetsagemakerpipelineparameters.html#cfn-pipes-pipe-pipetargetsagemakerpipelineparameters-pipelineparameterlist | ||
* @default - none | ||
*/ | ||
readonly pipelineParameters?: Record<string, string>; | ||
} | ||
|
||
/** | ||
* An EventBridge Pipes target that sends messages to a SageMaker pipeline. | ||
*/ | ||
export class SageMakerTarget implements ITarget { | ||
private pipeline: IPipeline; | ||
private sageMakerParameters?: SageMakerTargetParameters; | ||
private pipelineParameters?: Record<string, string>; | ||
public readonly targetArn: string; | ||
|
||
constructor(pipeline: IPipeline, parameters?: SageMakerTargetParameters) { | ||
this.pipeline = pipeline; | ||
this.targetArn = pipeline.pipelineArn; | ||
this.sageMakerParameters = parameters; | ||
this.pipelineParameters = this.sageMakerParameters?.pipelineParameters; | ||
} | ||
|
||
grantPush(grantee: IRole): void { | ||
this.pipeline.grantStartPipelineExecution(grantee); | ||
} | ||
|
||
bind(pipe: IPipe): TargetConfig { | ||
if (!this.sageMakerParameters) { | ||
return { targetParameters: {} }; | ||
} | ||
|
||
return { | ||
targetParameters: { | ||
inputTemplate: this.sageMakerParameters.inputTransformation?.bind(pipe).inputTemplate, | ||
sageMakerPipelineParameters: { | ||
pipelineParameterList: this.pipelineParameters ? | ||
Object.entries(this.pipelineParameters).map(([key, value]) => ({ | ||
name: key, | ||
value: value, | ||
})) : undefined, | ||
}, | ||
}, | ||
}; | ||
} | ||
} |
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
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
49 changes: 49 additions & 0 deletions
49
packages/@aws-cdk/aws-pipes-targets-alpha/test/__snapshots__/sagemaker.test.ts.snap
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,49 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`SageMaker should grant pipe role push access 1`] = ` | ||
{ | ||
"MyPipeRoleCBC8E9AB": { | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "pipes.amazonaws.com", | ||
}, | ||
}, | ||
], | ||
"Version": "2012-10-17", | ||
}, | ||
}, | ||
"Type": "AWS::IAM::Role", | ||
}, | ||
} | ||
`; | ||
|
||
exports[`SageMaker should grant pipe role push access 2`] = ` | ||
{ | ||
"MyPipeRoleDefaultPolicy31387C20": { | ||
"Properties": { | ||
"PolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sagemaker:StartPipelineExecution", | ||
"Effect": "Allow", | ||
"Resource": "MyPipeline", | ||
}, | ||
], | ||
"Version": "2012-10-17", | ||
}, | ||
"PolicyName": "MyPipeRoleDefaultPolicy31387C20", | ||
"Roles": [ | ||
{ | ||
"Ref": "MyPipeRoleCBC8E9AB", | ||
}, | ||
], | ||
}, | ||
"Type": "AWS::IAM::Policy", | ||
}, | ||
} | ||
`; |
1 change: 1 addition & 0 deletions
1
....snapshot/asset.44e9c4d7a5d3fd2d677e1a7e416b2b56f6b0104bd5eff9cac5557b4c65a9dc61/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.