Official agent skill

SageMaker IAM Role Preflight

by huggingface in huggingface/skills

Finds or validates a usable SageMaker execution role before deploying or training, so scripts do not try to create IAM roles they lack permission to create.

OfficialApache-2.0Auto-check passedDevOps & Cloud

Install SageMaker IAM Role Preflight

skills CLI
$ npx skills add huggingface/skills --skill hf-cloud-sagemaker-iam-preflight -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install huggingface/skills hf-cloud-sagemaker-iam-preflight --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/huggingface/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/hf-cloud-sagemaker-iam-preflight .claude/skills/hf-cloud-sagemaker-iam-preflight && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
hf-cloud-sagemaker-iam-preflight
GitHub stars
11k
Used in
1 other repo
Token cost
~1.8k tokens
SKILL.md length
778 words
Files
5 (incl. scripts, references)
Skills in repo
25
Repo updated
First seen
Licence
Apache-2.0

At a glance

Finds or validates a usable SageMaker execution role before deploying or training, so scripts do not try to create IAM roles they lack permission to create.

  • Works in 3 steps: Did the user provide a role? → Discover existing roles → Create, only if discovery found nothing
  • Before creating a SageMaker endpoint, model or training job
  • SKILL.md covers Running the helpers…, Order of operations, What "validated" means and Minimum permissions, plus 1 more section
  • Runs Python scripts from its folder; calls aws, python3 and python

What it does

Every SageMaker resource needs an execution role that SageMaker assumes to read model artifacts from S3, pull serving containers from ECR and write logs. The skill sets an order of operations of discover, validate, and create only if necessary, because many deployments fail when a script tries to make a new role without looking for an existing one and the caller is an SSO principal with no IAM write permissions.

Two Python helpers do the work. check_role.py validates a role you supply by name or ARN, printing the ARN on success and the reason on stderr on failure. With no argument it lists roles matching common SageMaker naming patterns, ranks them by last-used date, checks trust policies in that order and returns the first usable ARN. A create_role.py script and JSON files for the trust policy and minimum permissions are also included.

Run the helpers from a shell where aws sts get-caller-identity already works, because they call the same aws binary and inherit its profile, region and SSO session. On Windows, use PowerShell directly rather than WSL or Git Bash, which often do not share the AWS configuration.

When your agent uses it

  • Before creating a SageMaker endpoint, model or training job
  • When no role ARN was given and a script is about to call iam:CreateRole
  • Diagnosing an AccessDenied error that mentions an IAM action

Example prompts

  • “Deploy this Hugging Face model to a SageMaker endpoint, but look for an existing execution role first.”
  • “Find a usable SageMaker execution role in my AWS account.”
  • “Check that AmazonSageMaker-ExecutionRole-training will work for a training job.”

Requirements

  • Python 3
  • The AWS CLI with working credentials or an SSO session

Workflow steps

3 steps, taken from the step headings in SKILL.md.

  1. Did the user provide a role?
  2. Discover existing roles
  3. Create, only if discovery found nothing

What it can do on your machine

Read from SKILL.md and the folder at commit c3ff942. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 2 files in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • aws
    • python3
    • python

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use aws, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

SageMaker IAM Role Preflight loads about 1.8k tokens when it runs, and up to ~2.1k if it reads all its reference files. Until then it costs about 162 tokens; SKILL.md has 778 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~162
When it runs · the whole SKILL.md, loaded when a task matches
~1.8k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~2.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from huggingface/skills at commit c3ff942, republished under its Apache-2.0 licence (© huggingface). 778 words, ~1,756 tokens.

Download SKILL.mdSave it as .claude/skills/hf-cloud-sagemaker-iam-preflight/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
hf-cloud-sagemaker-iam-preflight
description
Ensure a usable SageMaker execution role exists before deploying or training. Use this skill whenever about to create a SageMaker endpoint, model, training job, or any resource that requires an execution role. Use it especially when the user has not provided a role ARN explicitly, when scripts are about to call `iam:CreateRole`, or when an AccessDenied error mentions an IAM action. Never blindly call `iam:CreateRole` — always check for existing roles first. This skill prevents the most common SageMaker deployment failure: trying to create IAM resources from an SSO principal that has no IAM write permissions.

SageMaker IAM Preflight

Every SageMaker resource needs an execution role — the IAM role SageMaker assumes to read model artifacts from S3, pull serving containers from ECR, and write logs. Most deployments fail here because the script tried to create a new role without checking if a usable one already existed, then blew up because the caller is an SSO principal.

This skill encodes the right order: discover, validate, only create if necessary.

Running the helpers (cross-platform)

The helpers are Python so they run identically on Windows, macOS, and Linux:

bash
python3 scripts/check_role.py        # macOS / Linux
python  scripts/check_role.py        # Windows (PowerShell / cmd)

Run them from the shell where the AWS CLI already works — i.e. wherever aws sts get-caller-identity succeeds. The script shells out to that same aws binary and inherits the shell's profile, region, SSO session, proxy, and credential chain.

Windows / WSL / Git Bash caveat. Do not invoke these through a Bash shim (WSL, Git Bash, MSYS) on Windows. Those Bash environments frequently do not share the Windows AWS config, credentials, SSO sessions, environment variables, or proxy settings — so aws sts get-caller-identity fails inside Bash even when it works natively in PowerShell. (This is exactly why the old .sh helpers failed on Windows and were replaced with Python.) If you're in PowerShell, run python ...\check_role.py directly in PowerShell. If the helper still can't see your identity, run the same discovery natively (see "Native AWS CLI equivalent" below) in the shell where aws sts get-caller-identity returns your ARN.

Order of operations

Step 1 — Did the user provide a role?

Validate that one specifically:

bash
python3 scripts/check_role.py "<role-name-or-arn>"

On success it prints the ARN to stdout (exit 0). On failure it logs why on stderr. Don't try to silently fix a broken role — surface the problem.

Step 2 — Discover existing roles
bash
python3 scripts/check_role.py

Lists roles matching common SageMaker patterns (AmazonSageMaker-ExecutionRole-*, SageMakerExecutionRole*, etc.), ranks by last-used date (most recent first), validates trust policy in that order, returns the first usable ARN. Most accounts that have used SageMaker before already have one.

Why rank by last-used: in accounts with multiple roles (auto-generated 2021 role + manual project role + etc.), the alphabetically-first one is rarely the actively-maintained one. The most-recently-used role is more likely to have current policies — including cross-account ECR pull. The script prints the ranking so you can see which got picked.

IAM frequently reports no RoleLastUsed at all (tracking only covers recent activity). When every candidate ties at "never used", the script falls back to newest creation date — a newer role is more likely to have current policies than a 2021 leftover.

Show full SKILL.md (368 more words)Show less
Step 3 — Create, only if discovery found nothing

If the user can create (has IAM permissions):

bash
python3 scripts/create_role.py "<role-name>" "<model-bucket>"

Second arg scopes S3 access to a specific bucket. Omit if unknown; script warns and the user can update the policy later.

If the user cannot create (SSO principal — hf-cloud-aws-context-discovery will have flagged this):

Stop and surface this clearly. Don't retry alternative IAM operations hoping one works:

I can't find an existing SageMaker execution role, and you're authenticated via SSO so you can't create one directly. Please either:

  • Ask your AWS admin for a SageMaker execution role ARN, or
  • Have them grant your SSO permission set iam:CreateRole, iam:PutRolePolicy

Specific instructions get unblocked fast; vague "permission denied" messages don't.

What "validated" means

A role is usable when (1) it exists, (2) its trust policy allows sagemaker.amazonaws.com to sts:AssumeRole, and (3) its permissions grant only the actions and resources this deployment needs. See references/trust-policy.json for the canonical trust policy.

check_role.py verifies existence and trust because policy evaluation depends on the deployment's exact S3, ECR, logging, and optional output resources. Before deployment, inspect the selected role's policies and compare them with references/minimum-permissions.json; add only missing actions and scope them to the required resources. Do not attach AmazonSageMakerFullAccess or defer permission review until an AccessDenied failure.

Minimum permissions

references/minimum-permissions.json is the standalone inline policy for endpoint execution:

  • s3:GetObject + s3:ListBucket on the model artifact bucket
  • ECR pull permissions
  • CloudWatch logs and metrics

create_role.py installs this inline policy without attaching a managed FullAccess policy. Replace REPLACE_WITH_MODEL_BUCKET in the template with the actual bucket name — create_role.py does this automatically when given a bucket as its second argument. Add narrowly scoped permissions separately for optional features such as async output or data capture.

Native AWS CLI equivalent (fallback)

If the Python helper can't run or can't see your identity (rare — usually a broken PATH or running under a Bash shim that lacks AWS context), do the same preflight by hand in the shell where aws sts get-caller-identity works. The logic is just AWS CLI calls; the helper exists only to bundle and rank them.

PowerShell:

powershell
# 1. List candidate SageMaker roles
aws iam list-roles --query "Roles[?contains(RoleName,'SageMaker') || contains(RoleName,'sagemaker')]" --output json

# 2. For each candidate, confirm the trust policy allows sagemaker.amazonaws.com
aws iam get-role --role-name <role-name> --query "Role.AssumeRolePolicyDocument" --output json

# 3. Prefer the most-recently-used role with SageMaker-execution naming
#    (LastUsedDate is often None for every role — then prefer newest CreateDate)
aws iam get-role --role-name <role-name> --query "Role.[RoleLastUsed.LastUsedDate, CreateDate]" --output text

Pick the most-recently-used role whose trust policy contains sagemaker.amazonaws.com. Use the resulting ARN exactly as if check_role.py had returned it. Bash/macOS/Linux use the same commands.

© huggingface, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 4 other files (scripts, references) in skills/hf-cloud-sagemaker-iam-preflight of huggingface/skills.

  • SKILL.md
  • references/minimum-permissions.json
  • references/trust-policy.json
  • scripts/check_role.py
  • scripts/create_role.py

Open the folder on GitHubat commit c3ff942

Used in 1 other repository

We found 1 copy of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in huggingface/skills, which our catalogue first saw on October 7, 2026.

Compare with similar skills

SageMaker IAM Role Preflight next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

SageMaker IAM Role Preflight compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
SageMaker IAM Role Preflight this skillhuggingface/skills11k1 repos~1.8kAutomated safety check: PassApache-2.0
Sagemaker AI Ops Reviewaws/tools-for-devops-agent102—~3.9kAutomated safety check: PassApache-2.0
SDK Getting Startedawslabs/agent-plugins915—~248Automated safety check: PassApache-2.0
AWS AI MLaws/agent-toolkit-for-aws2.8k—~1.7kAutomated safety check: PassApache-2.0
Hyperpod Version Checkerawslabs/agent-plugins915—~910Automated safety check: PassApache-2.0
Hf Cloud Sagemaker Iam Preflightwaybarrios/opencode-power-pack533—~1.6kAutomated safety check: PassApache-2.0

Similar skills

  • Sagemaker AI Ops Review

    aws/tools-for-devops-agent

    Official

    Amazon SageMaker AI Operational Review. An agent skill from aws/tools-for-devops-agent.

    102 GitHub stars~3.9k tokensUpdated yesterday
    DevOps & CloudAuto-check passed
  • SDK Getting Started

    awslabs/agent-plugins

    Official

    Validates the user's environment for SageMaker AI operations — checks SDK version, AWS region, and execution role.

    915 GitHub stars~248 tokensUpdated today
    DevOps & CloudAuto-check passed
  • AWS AI ML

    aws/agent-toolkit-for-aws

    Official

    Selects, deploys, and customizes AI models on Amazon SageMaker.

    2.8k GitHub stars~1.7k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Hyperpod Version Checker

    awslabs/agent-plugins

    Official

    Check and compare software component versions on SageMaker HyperPod cluster nodes - NVIDIA drivers, CUDA toolkit, cuDNN, NCCL, EFA, AWS OFI NCCL, GDRCopy, MPI, Neuron SDK (Trainium/Inferentia)…

    915 GitHub stars~910 tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Hf Cloud Sagemaker Iam Preflight

    waybarrios/opencode-power-pack

    Verify or select a SageMaker execution role before creating models, endpoints, or training jobs.

    533 GitHub stars~1.6k tokensUpdated 3 days ago
    SecurityAuto-check passed
  • AWS Cdk Development

    zxkane/aws-skills

    AWS Cloud Development Kit (CDK) expert for building cloud infrastructure with TypeScript/Python.

    367 GitHub starsUsed in 2 repos~2.5k tokens
    DevOps & CloudAuto-check passed

More from huggingface/skills

All 25 skills in this repo
  • Official

    Chooses the right serving container and current image URI for deploying a Hugging Face model to a SageMaker endpoint, preferring Hugging Face images over generic ones.

    11k GitHub starsUsed in 1 repo~4.6k tokens
    Auto-check passed
  • Official

    Routes a sentence-transformers training task to the right model type and required reference docs and example scripts, covering bi-encoders, rerankers, sparse and multi-vector models.

    11k GitHub starsUsed in 1 repo~2.6k tokens
    Auto-check passed
  • Official

    Sets up an isolated Python environment with a supported interpreter and current boto3 before any SageMaker deployment, training or AWS automation code runs.

    11k GitHub starsUsed in 2 repos~1.7k tokens
    Auto-check passed
  • Official

    Runs evaluations of Hugging Face Hub models on local hardware with inspect-ai or lighteval, and helps choose between vLLM, Transformers and accelerate backends.

    11k GitHub starsUsed in 2 repos~1.6k tokens
    Auto-check passed
  • Official

    Deploys SageMaker endpoints with autoscaling, CloudWatch alarms and tags on by default, using scripts for real-time, scale-to-zero and async setups.

    11k GitHub starsUsed in 1 repo~6.9k tokens
    Auto-check passed
  • Official

    Indexes research papers on the Hugging Face Hub from arXiv, links them to models and datasets, claims authorship and generates markdown research articles from templates.

    11k GitHub starsUsed in 4 repos~4.2k tokens
    Auto-check passed

Questions about SageMaker IAM Role Preflight

What does SageMaker IAM Role Preflight do?

Finds or validates a usable SageMaker execution role before deploying or training, so scripts do not try to create IAM roles they lack permission to create. Every SageMaker resource needs an execution role that SageMaker assumes to read model artifacts from S3, pull serving containers from ECR and write logs. The skill sets an order of operations of discover, validate, and create only if necessary, because many deployments fail when a script tries to make a new role without looking for an existing one and the caller is an SSO principal with no IAM write permissions.

When should I use SageMaker IAM Role Preflight?

SageMaker IAM Role Preflight fits situations like: before creating a SageMaker endpoint, model or training job; when no role ARN was given and a script is about to call iam:CreateRole; diagnosing an AccessDenied error that mentions an IAM action.

How do I install SageMaker IAM Role Preflight in Claude Code?

Run `npx skills add huggingface/skills --skill hf-cloud-sagemaker-iam-preflight -a claude-code`. Or copy the skill folder (skills/hf-cloud-sagemaker-iam-preflight in huggingface/skills) into .claude/skills/hf-cloud-sagemaker-iam-preflight in your project. Claude Code loads it when a task matches its description.

How do I install SageMaker IAM Role Preflight in Codex?

Run `npx skills add huggingface/skills --skill hf-cloud-sagemaker-iam-preflight -a codex`. Or copy the skill folder (skills/hf-cloud-sagemaker-iam-preflight in huggingface/skills) into .agents/skills/hf-cloud-sagemaker-iam-preflight in your project. Codex loads it when a task matches its description.

Can I use SageMaker IAM Role Preflight in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add huggingface/skills --skill hf-cloud-sagemaker-iam-preflight -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/hf-cloud-sagemaker-iam-preflight, .gemini/skills/hf-cloud-sagemaker-iam-preflight, .github/skills/hf-cloud-sagemaker-iam-preflight and .opencode/skills/hf-cloud-sagemaker-iam-preflight in your project.

What does SageMaker IAM Role Preflight need to run?

Going by SKILL.md and its folder, SageMaker IAM Role Preflight needs Python for the scripts in its folder and the command-line tools its instructions call (aws, python3 and python). Our summary lists: Python 3; The AWS CLI with working credentials or an SSO session.

Does SageMaker IAM Role Preflight access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is SageMaker IAM Role Preflight safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does SageMaker IAM Role Preflight use?

SageMaker IAM Role Preflight is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does SageMaker IAM Role Preflight use?

About 1.8k tokens (SKILL.md is roughly 7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 310 tokens, read only when the agent opens those files.

What are the alternatives to SageMaker IAM Role Preflight?

Skills that share tags, products or a category with SageMaker IAM Role Preflight: Sagemaker AI Ops Review (aws/tools-for-devops-agent, 102 stars), SDK Getting Started (awslabs/agent-plugins, 915 stars), AWS AI ML (aws/agent-toolkit-for-aws, 2.8k stars) and Hyperpod Version Checker (awslabs/agent-plugins, 915 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains SageMaker IAM Role Preflight?

huggingface (a GitHub organization, an official publisher) maintains it in huggingface/skills, which has 11,151 GitHub stars. The repository holds 25 skills in this directory. The repository was last updated on October 8, 2026.

Source: huggingface/skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.