setting-up-ec2-instance-profiles
An agent skill by aws, from aws/agent-toolkit-for-aws. Tags: cloud, ec2, iam, security, setup.
What it does
Configures EC2 instances to securely call AWS services by creating and attaching IAM roles via instance profiles, eliminating hardcoded credentials. Use when an EC2 instance needs permissions to access AWS services like S3, DynamoDB, SQS, or CloudWatch through temporary credentials.
Install
With the skills CLI, which installs into Claude Code, Codex, Cursor and other agents:
npx skills add aws/agent-toolkit-for-aws --skill setting-up-ec2-instance-profiles
Or copy the skill folder into Claude Code's skills directory by hand (~/.claude/skills for every project, or .claude/skills inside one):
git clone --depth 1 https://github.com/aws/agent-toolkit-for-aws
cp -r agent-toolkit-for-aws/skills/specialized-skills/ec2-skills/setting-up-ec2-instance-profiles ~/.claude/skills/setting-up-ec2-instance-profiles
Safety box score
Grade D, elevated risk: 53 of 100 risk points, rated 2026-10-19. The grade rates what the skill and its scripts can reach on the machine of whoever installs it, across eight categories from shell execution to secrets access. How the score works.
This skill configures EC2 instance profiles by creating/updating IAM roles, attaching policies, and associating the profile to an instance. The main risks are broad AWS-side privilege changes, destructive cleanup commands, and credential/metadata access during verification.
| Category | Level | Why |
|---|---|---|
| Code & shell execution | 2 (moderate) | The skill drives real shell/AWS CLI execution such as `aws ec2 describe-instances`, `aws iam create-role`, and `curl` to IMDS; it does not ship an executable script, but it does instruct the agent to run commands. |
| Network access | 2 (moderate) | It contacts AWS APIs and the instance metadata service, including `http://169.254.169.254/latest/...`, which sends requests off-box and to a raw link-local IP. |
| Filesystem reach | 2 (moderate) | It explicitly reaches outside the project into the user's home area with `~/.aws/credentials` and other config files when removing hardcoded credentials. |
| Secrets & credentials | 2 (moderate) | The skill handles credential material directly, including `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `~/.aws/credentials`, and IMDS session tokens. |
| Privilege & persistence | 2 (moderate) | It requires and exercises powerful AWS permissions like `iam:CreateRole`, `iam:AttachRolePolicy`, `iam:CreateInstanceProfile`, and `ec2:AssociateIamInstanceProfile`. |
| Instruction hijack surface | 0 (none) | I found no hidden text, remote prompt-following, or instructions to ignore safeguards; the file's directives are operational, not prompt injection. |
| Irreversible actions | 3 (high) | Its purpose is to change AWS infrastructure and permissions, including associating/disassociating instance profiles and deleting roles/policies during cleanup. |
| Transparency | 0 (none) | The skill is plain Markdown with readable commands and no binaries, installers, base64 blobs, or decoded-at-runtime code. |
Before installing
- Read the cleanup section first; it can delete roles, instance profiles, and policy attachments.
- Test it on a non-production EC2 instance because attachment changes permissions immediately.
- Confirm the AWS identity you will use can create/attach/delete IAM roles and instance profiles.
- Check whether you have hardcoded AWS credentials in `~/.aws/credentials` or env vars before running it.
Rated 2026-10-19 by an automated review of 2 files from the skill's repository.
Source
- Repository
- aws/agent-toolkit-for-aws (all skills from this repository)
- Path
- skills/specialized-skills/ec2-skills/setting-up-ec2-instance-profiles/SKILL.md
- Branch
- main
- Updated
- 2026-09-19
Related skills
- setup-security-agent — Configure AWS Security Agent for the current workspace — provision or reuse an agent space, IAM service role, and S3 bucket.
- launching-ec2-instance-with-best-practices — Launches an EC2 instance with secure, cost-efficient defaults including AMI selection, burstable instance sizing, least-privilege IAM roles.
- agents-harden — Use when preparing your agent for production — IAM scoping, inbound auth (JWT, SigV4), secrets management, cold start optimization, session lifecycle.
- agents-pay — Use when THIS agent needs to pay for x402-protected content at runtime: hitting a paywall mid-task, settling it via AgentCore Payments.
- aws-cloudformation — Authors, validates, and troubleshoots AWS CloudFormation templates.
- aws-iam — Provides verified corrections for IAM behaviors that AI agents frequently get wrong — policy evaluation edge cases, trust policy gotchas, STS session limits.