hf-cloud-sagemaker-iam-preflight
Ce qu’il fait
Cette compétence s'assure qu'un rôle d'exécution SageMaker existe et est utilisable avant tout déploiement. Elle s'adresse aux personnes qui déploient des modèles sur AWS et veulent éviter les erreurs d'autorisation.
Quand l’utiliser
- ✓Quand vous êtes sur le point de créer un point de terminaison, un modèle ou une tâche d'entraînement SageMaker.
- ✓Quand vous n'avez pas fourni d'ARN de rôle et que l'agent en a besoin.
- ✓Quand une erreur indique AccessDenied et mentionne une action IAM.
Lien du skill
https://github.com/huggingface/skills/blob/main/skills/hf-cloud-sagemaker-iam-preflight/SKILL.mdCopiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.
Comment l’utiliser
Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.
Message prêt à coller
Pour Claude Code, Codex ou Cursor : lancez-la dans le dossier du projet et le skill est installé.
Téléchargez le SKILL.md et placez-le dans le dossier de skills de votre agent.
Exemple de demande à votre IA
“Vérifie si j'ai un rôle d'exécution SageMaker utilisable avant que nous déployions ce modèle.”
5 nouveaux skills par semaine. 1 minute de lecture.
Comment ça marche
L'IA cherche d'abord un rôle existant adapté et le vérifie. Elle ne crée un nouveau rôle que si aucun rôle utilisable n'existe. Elle exécute de petits scripts d'aide Python qui fonctionnent de la même façon sous Windows, Mac et Linux.
Contenu technique (SKILL.md original)
Texte original de l’auteur, en anglais, directement depuis 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
Questions fréquentes
Crée-t-elle automatiquement un nouveau rôle IAM ?
Seulement si aucun rôle utilisable n'existe. Elle vérifie d'abord les rôles existants.
Pourquoi le type de connexion compte-t-il ?
Certains types de connexion ne peuvent pas créer de rôles, donc la compétence vérifie d'abord ce que votre compte est autorisé à faire.
Puis-je lancer les scripts d'aide sous Windows ?
Oui. Ils sont écrits en Python et doivent être lancés depuis le shell où la commande AWS fonctionne déjà.
Détails
Description originale de l’auteur
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
Popularité
- Étoiles GitHub
- 11k
- Position au classement
- #11769
- Licence
- Apache-2.0
- Mis à jour
- 30/10/2026
Commentaires
- …
Autres skills de ce dépôt
hf-cli
11kAide votre agent à utiliser l'outil en ligne de commande Hugging Face pour télécharger, téléverser et gérer des modèles, jeux de données, Spaces, dépôts et le cache local.
hf-cloud-aws-context-discovery
11kAide votre agent à trouver votre profil AWS, votre région et les détails de votre compte avant tout travail cloud, pour qu'il ne devine pas quel compte utiliser.
hf-cloud-python-env-setup
11kAide votre agent à mettre en place un environnement Python propre, avec une version adaptée et des bibliothèques à jour, avant d'exécuter SageMaker ou des automatisations AWS.
hf-cloud-sagemaker-deployment-planner
11kAide votre agent à planifier le déploiement d'un modèle sur Amazon SageMaker, en choisissant un hébergement en temps réel, sans serveur, asynchrone ou par lots, avec des valeurs par défaut raisonnables.
Skills similaires
reverse-engineer-anything
422kAide votre agent à analyser les applications et paquets livrés, pour expliquer leurs fonctions, comparer des versions ou guider une reconstruction, avec REA.
1password
394kAide votre agent à configurer l'interface en ligne de commande de 1Password, à se connecter, et à lire ou injecter des secrets sans afficher leurs valeurs dans le chat.
healthcheck
394kAide votre agent à auditer l'ordinateur ou le serveur qui fait tourner OpenClaw pour détecter des risques de sécurité, comme SSH, le pare-feu, les mises à jour et les sauvegardes, puis à proposer des corrections sûres.