Agent Native

hf-cloud-sagemaker-iam-preflight

This skill validates or creates an AWS IAM execution role before deploying SageMaker endpoints, training jobs, or models.

by Hugging FaceOfficial publisherNot reviewed

Identity proven by GitHub's verified organisation badge (huggingface)

Agents
Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode
License
Apache-2.0 (permissive)
Pin
c3ff942pinned Oct 9, 2026
Context cost
about 1,600 tokenswhen the skill loads
GitHub stars
11,150on huggingface/skills
Scripts
2 scripts

What it does

“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.”
The author's description, from SKILL.md

Generated summary from the skill's own text

This skill validates or creates an AWS IAM execution role before deploying SageMaker endpoints, training jobs, or models. It checks for existing roles matching SageMaker patterns, validates their trust policies, and only creates a new role if none exist and the user has IAM write permissions. It prevents common deployment failures caused by SSO principals attempting to create IAM resources without proper permissions.

When to use it

  • Deploying SageMaker endpoints or training jobs without a pre-provided role ARN
  • Encountering AccessDenied errors mentioning IAM actions in SageMaker workflows
  • Working with SSO-authenticated AWS accounts with uncertain IAM role availability
  • Automating SageMaker deployments across multiple accounts with varying role configurations

When not to

  • Role ARN is already validated and confirmed working in the deployment
  • User has no AWS IAM access and no admin to create roles
  • Using SageMaker within a locked-down AWS environment with pre-managed roles

Install

These commands install from the publisher's repository and need no account.

skills CLI

npx skills add huggingface/skills --skill hf-cloud-sagemaker-iam-preflight

Installs from the repository's default branch, which may have changed since the commit we checked.

GitHub CLI 2.90 or later

gh skill install huggingface/skills hf-cloud-sagemaker-iam-preflight@c3ff942be3e07116b475253f0a8fc4f54682c1a8

Installs the commit we checked (c3ff942).

Copy by hand

Download the folder at c3ff942 and put it in .claude/skills/hf-cloud-sagemaker-iam-preflight for Claude Code and in .agents/skills/hf-cloud-sagemaker-iam-preflight for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode.

Skill folder on GitHub at c3ff942

Claude Code plugin

/plugin install huggingface-skills@claude-plugins-official

The publisher's plugin in Claude's official marketplace. It may hold more than this skill, and we have not pinned it.

Copy for your agent

A prompt for any coding agent. It installs this skill from GitHub at the pinned commit, copies the files as they are, and runs nothing unless you ask.

Prompt

Install the agent skill "hf-cloud-sagemaker-iam-preflight" by Hugging Face.

Source, pinned to commit c3ff942be3e07116b475253f0a8fc4f54682c1a8:
https://github.com/huggingface/skills/tree/c3ff942be3e07116b475253f0a8fc4f54682c1a8/skills/hf-cloud-sagemaker-iam-preflight

1. Download that folder at exactly this commit. Do not use the default branch.
2. Copy every file unchanged, keeping the folder structure, into .claude/skills/hf-cloud-sagemaker-iam-preflight/ for Claude Code and .agents/skills/hf-cloud-sagemaker-iam-preflight/ for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode. Create the folders if they do not exist.
3. Do not edit the files, and do not run any script in the folder unless I ask you to.
4. When you are done, list the files you copied and where you put them.

Listing and checks: https://www.agentnative.dev/skills/hugging-face/hf-cloud-sagemaker-iam-preflight

SKILL.md at the pin

---
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.

### 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.

From huggingface/skills at c3ff942, shown as plain text under its license: Apache-2.0 (permissive). The license text is in LICENSE.

View SKILL.md on GitHub at c3ff942

Files

5 files, 19 KB in total. Each file has a sha256 in the pin's manifest; the first 12 characters are shown.

Skill folder on GitHub at c3ff942

More from Hugging Face

  • hf-cloud-aws-context-discovery

    This skill reads the user's local AWS configuration to discover their active profile, region, account ID, and caller identity before any AWS work begins.

    Claude Code, Codex, Cursor +4 · about 830 tokens · pinned 6 days ago

  • hf-cloud-python-env-setup

    Sets up an isolated Python environment for SageMaker and AWS work with the correct Python version (3.10, 3.11, or 3.12) and current boto3 and awscli.

    Contains scripts

    Claude Code, Codex, Cursor +3 · about 1.5K tokens · pinned 6 days ago

  • hf-cloud-sagemaker-deployment-planner

    This skill helps users plan and execute deployments of machine learning models to Amazon SageMaker by gathering requirements, selecting appropriate deployment…

    Claude Code, Codex, Cursor +4 · about 1.9K tokens · pinned 6 days ago

  • hf-cloud-sagemaker-production-defaults

    Deploys SageMaker endpoints with production defaults: autoscaling based on traffic, CloudWatch alarms for latency and errors, and consistent tagging.

    Contains scripts

    Claude Code, Codex, Cursor +3 · about 6.7K tokens · pinned 6 days ago

  • hf-cloud-serving-image-selection

    This skill helps select the correct SageMaker serving container image for model deployments and retrieves its current URI from AWS's Deep Learning Containers…

    Contains scripts

    Claude Code, Codex, Cursor +3 · about 4.3K tokens · pinned 6 days ago

  • hf-mcp

    This skill connects the agent to Hugging Face Hub via MCP server, enabling searches across models, datasets, Spaces, and papers.

    Claude Code, Codex, Cursor +4 · about 1.2K tokens · pinned 6 days ago

All Cloud and DevOps skills
  • agent-advisor

    Guides startups through a phased decision process to choose an AWS runtime for AI agents (AgentCore, ECS, EKS, Lambda, or Lambda MicroVMs), plan migrations of…

    by Amazon (AWS)Official publisher

    Contains scripts

    Claude Code · about 4.6K tokens · pinned 6 days ago

  • amazon-eventbridge-event-bus

    Enables building event-driven applications on AWS EventBridge custom event buses with publish/subscribe routing, event retention, filtering, transformation…

    by Amazon (AWS)Official publisher

    Claude Code, Codex, Cursor +3 · about 8.4K tokens · pinned 6 days ago

  • architect-for-startups

    Provides stage-appropriate AWS architecture guidance for startups from pre-revenue through Series B+, considering runway, team size, and AWS credits.

    by Amazon (AWS)Official publisher

    Claude Code, Codex, Cursor +4 · about 3.4K tokens · pinned 6 days ago

  • aws-containers

    Provides domain expertise for deploying and managing containerized workloads on AWS using EKS, ECS, Fargate, and Elastic Beanstalk.

    by Amazon (AWS)Official publisher

    Claude Code, Codex, Cursor +4 · about 1.4K tokens · pinned 6 days ago

  • aws-fault-injection-service

    Plans, builds, runs, and analyzes chaos engineering experiments using AWS Fault Injection Service to test application resilience.

    by Amazon (AWS)Official publisher

    Claude Code, Codex, Cursor +3 · about 1.9K tokens · pinned 6 days ago

  • aws-lambda-managed-instances

    Evaluates and migrates AWS Lambda workloads to Lambda Managed Instances, which run functions on EC2 instances while AWS handles provisioning, patching, and…

    by Amazon (AWS)Official publisher

    Claude Code, Codex, Cursor +3 · about 3.5K tokens · pinned 6 days ago

Open roles at Hugging Face

The skills listed here are third-party software, collected from public GitHub repositories as a catalog of recent skills and provided as is. Agent Native does not write or control them and is not responsible for any harm, loss or damage caused by installing or using them. Labels and checks describe what we saw at one commit and are not a guarantee. Read a skill's files before you run it. Terms of use