- Review built‑in SageMaker Project templates.
- Use a template that provisions a Git‑compatible repository (AWS CodeCommit in this demo).
- Inspect the CloudFormation template that the SageMaker Project uses and follow the resulting CI/CD flow (CodeCommit → CodePipeline → CodeBuild → SageMaker Pipelines → Model Registry → deployment).



Create a SageMaker Project from a Template
From SageMaker Studio navigate to Deployments → Projects and choose a project template. Templates are blueprints that create all required CI/CD and ML infra (for example: CodeCommit repos, CodeBuild projects, CodePipeline pipelines, S3 artifacts buckets, SageMaker Pipelines, IAM roles) using a CloudFormation stack.Effective September 9, 2024, SageMaker project templates that create AWS CodeCommit repositories are deprecated. This demo uses a CodeCommit template to show the in-console experience, but for production consider third‑party Git providers (e.g., GitHub) with a CodeStar connection or equivalent.
- a model‑build pipeline (trains and registers models), and
- a model‑deploy pipeline (staging → production with a manual approval gate).




Inspect the Generated Code Repositories
The CloudFormation stack created two source repositories (model‑build and model‑deploy). Open CodeCommit to review the seed code: buildspecs, helper scripts, CloudFormation templates, and the sample SageMaker pipeline code that the build runs.
CodePipeline: CI/CD Orchestration
The project provisions two CodePipeline pipelines:- Model build pipeline — triggers on commits to the model‑build repo, runs CodeBuild to create and execute a SageMaker Pipeline that preprocesses, trains, evaluates, and registers a model.
- Model deploy pipeline — triggers on commits to the model‑deploy repo or on model approval events; packages CloudFormation templates and deploys staging and production endpoints. A manual approval action gates production.


CodeBuild: How the Pipeline Invokes a SageMaker Pipeline
During the build stage, CodePipeline invokes a CodeBuild project. CodeBuild executes the repository’s buildspec.yml which installs dependencies and runs a helper that programmatically creates and executes the SageMaker Pipeline. Representative buildspec from the model‑build repository:run-pipeline invocation which creates and starts the SageMaker Pipeline:
run-pipeline call builds the SageMaker Pipeline in the same account/region. That pipeline orchestrates Processing, Training, and Evaluation jobs.
SageMaker Pipelines: Processing → Training → Evaluation → Model Registry
Open SageMaker Pipelines in the console to inspect the generated pipeline and its execution. A typical pipeline graph includes nodes for Preprocess, Train, Evaluate, a model‑quality check (e.g., CheckMSE), and RegisterModel.



Approve the Model; Trigger the Model Deploy Pipeline
Approving the model package in the Model Registry will trigger the deploy pipeline if an EventBridge rule or pipeline trigger is configured. Approve the model in the SageMaker console by changing the model package status from pending to approved and adding an optional comment.
- Run a helper (e.g., build.py) to generate endpoint configuration CloudFormation templates for staging and prod.
- Package templates with
aws cloudformation packageand upload artifacts to the project S3 bucket. - Emit packaged template files as pipeline artifacts.

Inspect CodeBuild Projects
Both pipelines use CodeBuild. In the CodeBuild console you can open each build project to examine its environment, source settings, and buildspec.
run-pipeline, and package or deploy CloudFormation templates.
Third‑Party Git Integration (Optional)
If you prefer to use GitHub, GitLab, Bitbucket, or GitHub Enterprise, choose a template that supports third‑party Git. You must first create a CodeStar connection between your AWS account and the Git provider (Developer Tools → Settings → Connections). The project creation dialog will then request repository URLs and branch names instead of creating CodeCommit repos.

Resources Created by the Template
Summary
What we accomplished:- Reviewed SageMaker Project templates and selected one that provisions both model build and model deploy CI/CD pipelines.
- Created a SageMaker Project, which launched a CloudFormation stack to provision S3, source repos, CodeBuild projects, CodePipeline pipelines, SageMaker Pipelines, and IAM roles.
- Followed the CI/CD flow: CodeCommit → CodePipeline → CodeBuild → run‑pipeline (SageMaker Pipeline) → Processing/Training/Evaluation → Model Registry.
- Approved a registered model to trigger the deploy pipeline; observed staging deployment, automated tests, and a manual approval gate before production.

- Prefer third‑party Git hosts and CodeStar connections,
- Define branching and approval policies,
- Consider cross‑account deployments and more robust testing (canaries, blue/green),
- Add monitoring and Model Monitor checks for production model behavior.
- SageMaker Projects & Templates: https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-projects.html
- SageMaker Pipelines: https://docs.aws.amazon.com/sagemaker/latest/dg/pipelines.html
- SageMaker Model Registry: https://docs.aws.amazon.com/sagemaker/latest/dg/model-registry.html
- AWS CodePipeline: https://docs.aws.amazon.com/codepipeline/latest/userguide/welcome.html
- AWS CodeBuild: https://docs.aws.amazon.com/codebuild/latest/userguide/welcome.html
- AWS CloudFormation: https://docs.aws.amazon.com/cloudformation/index.html
- CodeStar Connections (Git integrations): https://docs.aws.amazon.com/dtconsole/latest/userguide/connections.html