Skip to main content
skill CX Codex

setting-up-ec2-instance-profiles — Claude Code skill: how to install

Configures EC2 instance profiles and IAM roles so applications call AWS services without hardcoded credentials. Useful when an instance needs temporary access to S3, DynamoDB, or SQS.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add aws/agent-toolkit-for-aws --skill setting-up-ec2-instance-profiles -a claude-code
Open on GitHub

What setting-up-ec2-instance-profiles does

This skill guides the setup of EC2 instance profiles and least-privilege IAM roles. It covers determining required permissions, creating or reusing IAM roles, attaching them to virtual machines, and verifying credential availability. This eliminates the risk of storing long-term credentials in code repositories or configuration files.

When an instance already has an associated profile, the procedure prompts for confirmation before disassociating it. Instance profile propagation takes 30–60 seconds across the infrastructure. Applications may need a restart to pick up the newly attached role.

If an application keeps attempting to use old credentials, remove them from ~/.aws/credentials, configuration files, and the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY variables. Once cleared, the AWS SDK credential chain falls back to the instance profile. CloudTrail logs can confirm specific denied actions during permission debugging.

What it helps with

  • eliminate hardcoded AWS access keys from config files and environment variables
  • attach least-privilege IAM roles to EC2 virtual machines via instance profiles
  • grant applications temporary credentials for services like S3, DynamoDB, and CloudWatch
  • troubleshoot permission denials by inspecting CloudTrail logs

Example prompts for the agent

  • Set up an EC2 instance profile for this server to read and write to S3
  • Attach an IAM role to our EC2 instance so it can push logs to CloudWatch
  • Help remove static AWS access keys from this EC2 instance and switch to an IAM role

How to install setting-up-ec2-instance-profiles

1Skills CLI (Vercel)

npx skills add aws/agent-toolkit-for-aws --skill setting-up-ec2-instance-profiles -a claude-code

2Manually: put the files in place

~/.claude/skills/setting-up-ec2-instance-profiles/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/setting-up-ec2-instance-profiles/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about setting-up-ec2-instance-profiles

How do I install setting-up-ec2-instance-profiles in Claude Code?

Run npx skills add aws/agent-toolkit-for-aws --skill setting-up-ec2-instance-profiles -a claude-code in your terminal. The skill definition is saved to ~/.claude/skills/setting-up-ec2-instance-profiles/SKILL.md.

What does setting-up-ec2-instance-profiles do?

It configures IAM roles with least-privilege policies and attaches them to EC2 instances using instance profiles, enabling secure temporary credentials for AWS services.

Why is an application still using hardcoded AWS credentials after attaching a profile?

The application finds static credentials earlier in the SDK search chain. Remove the keys from ~/.aws/credentials, configuration files, and the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables.

Source text

SKILL.md · Apache-2.0
---
name: setting-up-ec2-instance-profiles
description: 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.
version: 1
---

# Setting Up EC2 Instance Profiles

## Overview

Domain expertise for granting EC2 instances secure access to AWS services using IAM roles
and instance profiles. Covers the full lifecycle: identifying required permissions, creating
or reusing IAM roles with least-privilege policies, creating instance profiles, attaching
them to EC2 instances, and verifying credential availability.

## Configure an EC2 instance profile

To set up an IAM role and instance profile for an EC2 instance, follow the procedure exactly.
See [EC2 instance profile setup procedure](references/ec2-instance-profile-setup.md).

## Troubleshooting

### Instance not found

Verify the instance ID and region are correct. List instances with `aws ec2 describe-instances --region <region>`.

### Instance already has a profile

The procedure handles replacement — it will prompt before disassociating the existing profile.

### Credentials not available after attachment

Instance profile propagation can take 30–60 seconds. Applications may need a restart to pick up new credentials.

### Access denied errors

Check that the role's policies include the required actions and resource ARNs. Review CloudTrail logs for the specific denied action.

### Application still uses hardcoded credentials

Remove credentials from config files, environment variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`), and `~/.aws/credentials`. The SDK default credential chain will then use the instance profile.

© aws · Apache-2.0 · aws/agent-toolkit-for-aws

Similar skills

Everything for Cloud: AWS, Azure, GCP →

From the same set133

launching-ec2-instance-with-best-practices This skill launches EC2 instances with security and cost controls in place. Use it when deploying a new AWS instance and checking its setup after launch. CX Codex +1 6,300installs setting-up-cloudwatch-alarm-notifications Wires CloudWatch alarms to notification channels through SNS: encrypted topics, subscriptions, access policies and alarm actions. CX Codex +1 6,300installs debugging-lambda-timeouts Investigates AWS Lambda timeout failures by inspecting CloudWatch logs, metrics, and configurations. Use it when function runs hit or approach execution limits. CX Codex +1 6,400installs configuring-vpc-endpoints-for-private-aws-service-access A skill that walks the agent through VPC endpoint setup with AWS PrivateLink, so AWS services stay reachable without an internet gateway or public IPs. CX Codex +1 6,400installs routing-traffic-with-route53-and-cloudfront Sets up Route 53 to send a custom domain to a CloudFront distribution with HTTPS and IPv6. Use it when creating alias records or connecting a domain to CloudFront. CX Codex +1 6,200installs creating-api-gateway-stage Builds an API Gateway stage with CloudWatch logging, X-Ray tracing, throttling and WAF. Handy when a REST API ships to dev, test or production. CX Codex +1 6,200installs creating-production-vpc-multi-az Plan a VPC across multiple Availability Zones, with public and private subnets, NAT gateways, routing, and security groups. Use it when setting up AWS network infrastructure. CX Codex +1 6,100installs creating-amazon-aurora-db-cluster-with-instances Creates Aurora cluster with instances, sets up password via Secrets Manager, and monitors status with retry logic. Supports MySQL and PostgreSQL. CX Codex +1 6,000installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor