The Simplest Way to Make AWS Sagemaker and GitLab CI Work Like They Should
Pairing aws sagemaker and gitlab ci lets teams train and ship machine learning models on every code push. GitLab CI runs the build steps and tells AWS SageMaker to start training or update an endpoint. Data teams want fast releases when they update model code. Platform teams need strict rules on who can start cloud jobs and read training data. A clean setup meets both goals without sharing static cloud keys. How aws sagemaker and gitlab ci pass roles and data GitLab CI runs jobs inside runne
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
Pairing aws sagemaker and gitlab ci lets teams train and ship machine learning models on every code push. GitLab CI runs the build steps and tells AWS SageMaker to start training or update an endpoint.
Data teams want fast releases when they update model code. Platform teams need strict rules on who can start cloud jobs and read training data. A clean setup meets both goals without sharing static cloud keys.
How aws sagemaker and gitlab ci pass roles and data
GitLab CI runs jobs inside runner hosts when a developer pushes code. Those runners must log in to AWS before they can start a SageMaker job. The safest way uses OpenID Connect between GitLab and AWS IAM.
With OpenID Connect, the runner sends a signed job token to AWS IAM. AWS checks the project path and branch name inside that token. If the rules match, AWS returns a short-lived role key for that single run.
The runner then calls the SageMaker API to start a training job or model build. SageMaker does not use the runner role to read training data. Instead, SageMaker uses its own execution role to read storage buckets and pull container images.
Keeping these two roles separate is very important for cloud safety. The GitLab runner role only needs permission to start jobs and check status. The SageMaker execution role holds the permissions to read data and write model outputs.
Common failure modes with shared keys and broad roles
Many teams start by putting static AWS keys into GitLab variables. This approach creates major risks as more people join the project. Static keys do not expire on their own, and anyone with maintainer rights might reuse them.
Broad IAM roles cause another common problem in machine learning setups. If a runner can pass any execution role to SageMaker, a pipeline could grab an admin role. You must restrict the runner so it can only pass one specific SageMaker role.
GitLab CI Security + AWS IAM Policies: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Unlogged database queries during feature building also create blind spots for security teams. Build pipelines and notebook users often query production databases to test new model features. When those jobs share one database password, audit logs cannot show which person or run read the data.
Sensitive fields like emails, phone numbers, and card numbers often sit in those source tables. If a training script pulls raw tables, personal data can leak into model weights or build logs. Data masking rewrites matched fields in results before the job or user processes them.
Scoping network paths and notebook checks
Production pipelines should run inside private cloud networks with strict outbound rules. Self-hosted GitLab runners inside your virtual private cloud can reach AWS endpoints over private links. This setup keeps model artifacts and job calls off the public internet.
SageMaker training containers should also run in network isolation mode when they do not need internet access. The platform downloads the data from storage, runs the code, and writes the model back out. If a bad package is inside the image, it cannot send data out to an external server.
Engineers also use SageMaker notebooks and shell tools to fix broken training runs. These manual checks need the same strict identity controls as automated GitLab jobs. Every database query or host check should tie back to an individual user identity with full command logs.
Check database and API queries on the wire
Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.
Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.
Frequently asked questions
How should GitLab CI log in to AWS for SageMaker jobs?
Use OpenID Connect so GitLab runners trade a job token for a temporary AWS IAM role. This removes the need to store long-lived AWS keys in your project settings.
How do we stop a GitLab pipeline from using the wrong SageMaker role?
Limit the IAM pass role permission on the GitLab runner role to the exact SageMaker execution role ARN. Also add a condition that only allows passing that role to the SageMaker service.
How can teams protect personal data during model data prep?
Apply dynamic data masking on databases so queries rewrite emails, phone numbers, and card numbers in results. This keeps raw personal fields out of training sets and notebook outputs.
Related guides
In this post