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, like the SageMaker Endpoint. It can be extended to include resources like AutoScalingPolicy, API Gateway, etc,. as required. Parameters: SageMakerProjectName: Type: String Description: Name of the project MinLength: 1 MaxLength: 32 AllowedPattern: ^[a-zA-Z](-*[a-zA-Z0-9])* ModelExecutionRoleArn: Type: String Description: Execution role used for deploying the model. ModelPackageName: Type: String Description: The trained Model Package Name CurrentProdModelPackageName: Type: String Description: Name of the current production model package (if exists) StageName: Type: String Description: The name for a project pipeline stage, such as Staging or Prod, for which resources are provisioned and deployed. DeployShadow: Type: String Description: Designates if there should be a shadow variant deployed. EndpointInstanceCount: Type: Number Description: Number of instances to launch for the endpoint. MinValue: 1 EndpointInstanceType: Type: String Description: The ML compute instance type for the endpoint. DataCaptureUploadPath: Type: String Description: The s3 path to which the captured data is uploaded. SamplingPercentage: Type: Number Description: The sampling percentage MinValue: 0 MaxValue: 100 EnableDataCapture: Description: Enable Data capture. Default: true Type: String AllowedValues: [true, false] Conditions: IsShadow: !Equals - !Ref DeployShadow - true Resources: CurrentModel: Type: AWS::SageMaker::Model Properties: Containers: - ModelPackageName: !Ref CurrentProdModelPackageName ExecutionRoleArn: !Ref ModelExecutionRoleArn ShadowModel: Type: AWS::SageMaker::Model Properties: Containers: - ModelPackageName: !Ref ModelPackageName ExecutionRoleArn: !Ref ModelExecutionRoleArn EndpointConfig: Type: AWS::SageMaker::EndpointConfig Properties: !If - IsShadow - ProductionVariants: - InitialInstanceCount: !Ref EndpointInstanceCount InitialVariantWeight: 1.0 InstanceType: !Ref EndpointInstanceType ModelName: !GetAtt CurrentModel.ModelName VariantName: ProductionTraffic DataCaptureConfig: EnableCapture: !Ref EnableDataCapture InitialSamplingPercentage: !Ref SamplingPercentage DestinationS3Uri: !Ref DataCaptureUploadPath CaptureOptions: - CaptureMode: Input - CaptureMode: Output CaptureContentTypeHeader: CsvContentTypes: - "text/csv" ShadowProductionVariants: - InitialInstanceCount: !Ref EndpointInstanceCount InitialVariantWeight: 1.0 InstanceType: !Ref EndpointInstanceType ModelName: !GetAtt ShadowModel.ModelName VariantName: ShadowTraffic - ProductionVariants: - InitialInstanceCount: !Ref EndpointInstanceCount InitialVariantWeight: 1.0 InstanceType: !Ref EndpointInstanceType ModelName: !GetAtt ShadowModel.ModelName VariantName: ProductionTraffic DataCaptureConfig: EnableCapture: !Ref EnableDataCapture InitialSamplingPercentage: !Ref SamplingPercentage DestinationS3Uri: !Ref DataCaptureUploadPath CaptureOptions: - CaptureMode: Input - CaptureMode: Output CaptureContentTypeHeader: CsvContentTypes: - "text/csv" Endpoint: Type: AWS::SageMaker::Endpoint Properties: EndpointName: !Sub ${SageMakerProjectName}-${StageName} EndpointConfigName: !GetAtt EndpointConfig.EndpointConfigName