hf-cloud-sagemaker-iam-preflight
What it does
This skill makes sure a SageMaker execution role exists and is usable before anything is deployed. It is for people deploying models on AWS who want to avoid permission errors.
When to use it
- βWhen you are about to create a SageMaker endpoint, model or training job.
- βWhen you have not given a role ARN and the agent needs one.
- βWhen an error says AccessDenied and mentions an IAM action.
Skill link
https://github.com/huggingface/skills/blob/main/skills/hf-cloud-sagemaker-iam-preflight/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βCheck whether I have a usable SageMaker execution role before we deploy this model.β
5 new skills a week. 1 minute to read.
How it works
The AI first looks for a suitable existing role and checks it. It creates a new role only when no usable one exists. It runs small Python helper scripts that work the same way on Windows, Mac and Linux.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
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:
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-identityfails inside Bash even when it works natively in PowerShell. (This is exactly why the old.shhelpers failed on Windows and were replaced with Python.) If you're in PowerShell, runpython ...\check_role.pydirectly 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 whereaws sts get-caller-identityreturns your ARN.
Order of operations
Step 1 β Did the user provide a role?
Validate that one specifically:
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
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.
Step 3 β Create, only if discovery found nothing
If the user can create (has IAM permissions):
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 `AmazonSageMakerF
FAQ
Will it create a new IAM role automatically?
Only when no usable role exists. It checks existing roles first.
Why does the sign-in type matter?
Some sign-in types cannot create roles, so the skill checks what your account is allowed to do first.
Can I run the helper scripts on Windows?
Yes. They are written in Python and should run from the shell where the AWS command line already works.
Details
Original description by the author
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 wri
repo: huggingface/skills
Popularity
- GitHub stars
- 11k
- Ranking position
- #11769
- License
- Apache-2.0
- Updated
- 10/30/2026
Comments
- β¦
More skills from this repository
hf-cli
11kHelps your agent use the Hugging Face command line tool to download, upload and manage models, datasets, Spaces, repos and the local cache.
hf-cloud-aws-context-discovery
11kHelps your agent find your AWS profile, region and account details before any cloud work, so it does not guess which account to use.
hf-cloud-python-env-setup
11kHelps your agent set up a clean Python environment with a suitable Python version and current libraries before running SageMaker or AWS automation.
hf-cloud-sagemaker-deployment-planner
11kHelps your agent plan how to deploy a model to Amazon SageMaker, choosing real-time, serverless, async or batch hosting with sensible defaults.
Similar skills
reverse-engineer-anything
422kHelps your agent look inside shipped apps and packages to explain features, compare versions, or guide a rebuild, using the REA tool.
1password
394kHelps your agent set up the 1Password CLI, sign in, and read or inject secrets without printing their values into chat.
healthcheck
394kHelps your agent audit the computer or server that runs OpenClaw for security risks, such as SSH, firewall, updates, and backups, then suggest safe fixes.