Loading...
Loading...
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.
npx skill4agent add huggingface/skills hf-cloud-sagemaker-iam-preflightpython3 scripts/check_role.py # macOS / Linux
python scripts/check_role.py # Windows (PowerShell / cmd)aws sts get-caller-identityawsWindows / 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 — sofails inside Bash even when it works natively in PowerShell. (This is exactly why the oldaws sts get-caller-identityhelpers failed on Windows and were replaced with Python.) If you're in PowerShell, run.shdirectly 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 wherepython ...\check_role.pyreturns your ARN.aws sts get-caller-identity
python3 scripts/check_role.py "<role-name-or-arn>"python3 scripts/check_role.pyAmazonSageMaker-ExecutionRole-*SageMakerExecutionRole*RoleLastUsedpython3 scripts/create_role.py "<role-name>" "<model-bucket>"hf-cloud-aws-context-discoveryI 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:AttachRolePolicyiam:PutRolePolicy
sagemaker.amazonaws.comsts:AssumeRolereferences/trust-policy.jsoncheck_role.pyiam:SimulatePrincipalPolicyAmazonSageMakerFullAccessreferences/minimum-permissions.jsons3:GetObjects3:ListBucketAmazonSageMakerFullAccesscreate_role.pyREPLACE_WITH_MODEL_BUCKETcreate_role.pyaws sts get-caller-identity# 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 textsagemaker.amazonaws.comcheck_role.py