Description: This template is built and deployed by the infrastructure pipeline in various stages (staging/production) as required. It specifies the resources that need to be created. In this case, an EventBridge Rule, a SageMaker Pipelines and a SageMake Model. Parameters: SageMakerProjectName: Type: String Description: Name of the project (lower case) MinLength: 1 MaxLength: 32 AllowedPattern: ^[a-z](-*[a-z0-9])* SageMakerProjectId: Type: String Description: Id of the project MinLength: 1 MaxLength: 32 ModelExecutionRoleArn: Type: String Description: Execution role used for deploying the model. ModelPackageName: Type: String Description: Name of the model to use InputPath: Type: String Description: The S3 path where data is stored on which to run inference. OutputPath: Type: String Description: The S3 path where predictions will be output. BatchInstanceType: Type: String Description: Which kind of instance you want to use for Batch inference Default: ml.m5.xlarge BatchInstanceCount: Type: Number Description: How many instances you want to use for inference. Default: 1 ScheduleExpressionforPipeline: Type: String Description: The rate of execution of your pipeline (default 30 minutes) Default: 30 minutes StageName: Type: String Description: The name for a project pipeline stage, such as dev or prod, for which resources are provisioned and deployed. PipelineDefinitionBody: Type: String Description: The body of the SageMaker Pipeline. Resources: ModelToDeploy: Type: AWS::SageMaker::Model Properties: ExecutionRoleArn: !Ref ModelExecutionRoleArn Containers: - ModelPackageName: !Ref ModelPackageName Tags: - Key: sagemaker:project-name Value: !Sub ${SageMakerProjectName} - Key: sagemaker:project-id Value: !Sub ${SageMakerProjectId} BatchPipeline: Type: AWS::SageMaker::Pipeline Properties: PipelineDescription: The SM Pipeline that executes the batch inference PipelineName: !Sub ${SageMakerProjectName}-${StageName}-BatchPipeline RoleArn: !Ref ModelExecutionRoleArn PipelineDefinition: PipelineDefinitionBody: !Ref PipelineDefinitionBody Tags: - Key: sagemaker:project-name Value: !Ref SageMakerProjectName - Key: sagemaker:project-id Value: !Ref SageMakerProjectId EventRule: Type: AWS::Events::Rule Properties: Name: !Sub sagemaker-${SageMakerProjectName}-${StageName}-SchedExecRule ScheduleExpression: !Sub rate(${ScheduleExpressionforPipeline}) Targets: - Arn: !Sub arn:aws:sagemaker:${AWS::Region}:${AWS::AccountId}:pipeline/${SageMakerProjectName}-${StageName}-batch-pipeline Id: MyBatchInferenceTarget RoleArn: !Ref ModelExecutionRoleArn SageMakerPipelineParameters: PipelineParameterList: - Name: InputPath Value: !Ref InputPath - Name: OutputPath Value: !Ref OutputPath - Name: BatchInstanceType Value: !Ref BatchInstanceType - Name: BatchInstanceCount Value: !Ref BatchInstanceCount - Name: ModelName Value: !GetAtt ModelToDeploy.ModelName Outputs: ModelName: Description: SageMaker model name Value: !GetAtt ModelToDeploy.ModelName