setting-up-ec2-instance-profiles

Create IAM roles and instance profiles for EC2 to access AWS services.

Updated May 12, 2026
One-click install
npx skills add https://github.com/mreferre/aws-agent-toolkit-skills --skill setting-up-ec2-instance-profiles
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: setting-up-ec2-instance-profiles
Source: https://github.com/mreferre/aws-agent-toolkit-skills/tree/main/.kiro/skills/setting-up-ec2-instance-profiles
Command: npx skills add https://github.com/mreferre/aws-agent-toolkit-skills --skill setting-up-ec2-instance-profiles

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you avoid hardcoded AWS credentials on EC2 by configuring IAM roles and instance profiles so your instance can securely access required AWS services using temporary credentials.

Core Features & Use Cases

  • IAM role + instance profile lifecycle: Create or reuse an IAM role, attach least-privilege permissions, create an instance profile, and associate it with a target EC2 instance.
  • Least-privilege permission planning: Recommend scoped actions per requested service (e.g., S3, DynamoDB, SQS, CloudWatch Logs) and steer you away from overly broad FullAccess policies.
  • Credential verification via IMDSv2: Provide explicit in-instance test steps to confirm the role can be assumed and credentials are available through the Instance Metadata Service.

Quick Start

Run the procedure in the Skill to configure the IAM role, create the instance profile, attach it to your EC2 instance, and verify credentials using IMDSv2.

Frequently Asked Questions about setting-up-ec2-instance-profiles

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I grant an EC2 instance least-privilege access to AWS services?

You grant EC2 instances least-privilege access by creating an IAM role with scoped permissions, wrapping it in an instance profile, and attaching that profile to the instance to provide temporary credentials.

What is the best way to avoid hardcoded AWS credentials on EC2?

To avoid hardcoded AWS credentials on EC2, configure IAM roles via instance profiles, allowing the instance to securely assume roles and access required services using temporary credentials.

How do I verify EC2 instance profile credentials using IMDSv2?

Verify EC2 instance profile credentials by running in-instance tests using IMDSv2 to confirm the role can be assumed and temporary credentials are available through the Instance Metadata Service.

Can I use least-privilege IAM roles for EC2 access to S3 and DynamoDB?

Yes, you can configure least-privilege IAM roles for EC2 access to S3, DynamoDB, SQS, and CloudWatch by attaching scoped permission policies to the instance profile.

Why should I use an IAM instance profile instead of FullAccess policies for EC2?

Using an IAM instance profile with scoped actions instead of FullAccess policies ensures least-privilege security, preventing overly broad permissions while securely delivering temporary credentials to the EC2 instance.

Does EC2 need an IAM trust policy to assume an instance profile role?

Yes, the IAM trust policy must explicitly allow the EC2 service to assume the role, ensuring the instance profile can securely provide temporary credentials for AWS API access.