मुख्य सामग्री पर जाएँ
Skillpedia
सिक्योरिटी11k · #11769

hf-cloud-sagemaker-iam-preflight

यह क्या करती है

यह स्किल सुनिश्चित करती है कि कुछ भी डिप्लॉय होने से पहले SageMaker execution role मौजूद और इस्तेमाल योग्य है। यह उन लोगों के लिए है जो AWS पर मॉडल डिप्लॉय करते हैं और अनुमति की गड़बड़ियों से बचना चाहते हैं।

कब इस्तेमाल करें

  • ✓जब आप SageMaker endpoint, model या ट्रेनिंग जॉब बनाने वाले हों।
  • ✓जब आपने role ARN नहीं दिया और एजेंट को उसकी ज़रूरत है।
  • ✓जब कोई त्रुटि AccessDenied कहे और किसी IAM कार्रवाई का ज़िक्र करे।

Skill का लिंक

https://github.com/huggingface/skills/blob/main/skills/hf-cloud-sagemaker-iam-preflight/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/huggingface/skills/blob/main/skills/hf-cloud-sagemaker-iam-preflight/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“इस मॉडल को डिप्लॉय करने से पहले जाँचिए कि मेरे पास इस्तेमाल योग्य SageMaker execution role है या नहीं।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

AI पहले कोई उपयुक्त मौजूदा role खोजकर उसे जाँचता है। कोई इस्तेमाल योग्य role न होने पर ही वह नया role बनाता है। यह छोटी Python सहायक स्क्रिप्ट चलाता है, जो Windows, Mac और Linux पर एक जैसी काम करती हैं।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे 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-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:

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

अक्सर पूछे जाने वाले सवाल

क्या यह अपने-आप नया IAM role बना देगी?

सिर्फ़ तब, जब कोई इस्तेमाल योग्य role मौजूद न हो। यह पहले मौजूदा roles जाँचती है।

साइन-इन का प्रकार क्यों मायने रखता है?

कुछ साइन-इन प्रकार role नहीं बना सकते, इसलिए स्किल पहले जाँचती है कि आपका खाता क्या कर सकता है।

क्या मैं Windows पर सहायक स्क्रिप्ट चला सकता हूँ?

हाँ। ये Python में लिखी हैं और उसी शेल में चलनी चाहिए जहाँ AWS कमांड लाइन पहले से काम करती है।

जानकारी

लेखक का मूल विवरण

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

लोकप्रियता

GitHub स्टार
11k
रैंकिंग में स्थान
#11769
लाइसेंस
Apache-2.0
अपडेट की गई
30/10/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

hf-cli

11k

यह आपके एजेंट को hf कमांड लाइन टूल से Hugging Face पर मॉडल, डेटासेट, Spaces, रिपो और लोकल कैश डाउनलोड करने, अपलोड करने और संभालने में मदद करती है।

डेटामशीन लर्निंग

hf-cloud-aws-context-discovery

11k

यह आपके एजेंट को किसी भी क्लाउड काम से पहले AWS प्रोफ़ाइल, क्षेत्र और खाते का विवरण खोजने में मदद करती है, ताकि वह अंदाज़ा लगाकर खाता न चुने।

कोडिंगडिप्लॉय और क्लाउड (DevOps)

hf-cloud-python-env-setup

11k

यह आपके एजेंट को SageMaker या AWS ऑटोमेशन चलाने से पहले सही Python संस्करण और ताज़ा लाइब्रेरी वाला साफ़ Python वातावरण सेट करने में मदद करती है।

कोडिंगडिप्लॉय और क्लाउड (DevOps)

hf-cloud-sagemaker-deployment-planner

11k

यह आपके एजेंट को मॉडल को Amazon SageMaker पर डिप्लॉय करने की योजना बनाने में मदद करती है, real-time, serverless, async या batch होस्टिंग में से सही विकल्प चुनकर।

कोडिंगडिप्लॉय और क्लाउड (DevOps)

मिलती-जुलती skills