setting-up-ec2-instance-profiles

Configure EC2 instances with IAM roles and instance profiles for AWS service access.

2.3k|234|Updated Apr 23, 2026
One-click install
npx skills add https://github.com/aws/agent-toolkit-for-aws --skill setting-up-ec2-instance-profiles-aws
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: setting-up-ec2-instance-profiles
Source: https://github.com/aws/agent-toolkit-for-aws/tree/main/skills/specialized-skills/ec2-skills/setting-up-ec2-instance-profiles
Command: npx skills add https://github.com/aws/agent-toolkit-for-aws --skill setting-up-ec2-instance-profiles-aws

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Configures EC2 instances to securely call AWS services by using IAM roles and instance profiles, avoiding hardcoded credentials.

Core Features & Use Cases

  • Create or reuse an IAM role with least-privilege policies and attach it to an instance profile.
  • Attach the instance profile to an EC2 instance and verify credentials via the Instance Metadata Service (IMDSv2).
  • Provide end-to-end testing guidance and cleanup steps for a reusable, production-grade workflow.

Quick Start

Configure an EC2 instance to securely access AWS services by attaching an IAM role via an instance profile and validating credential propagation.

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 securely give an EC2 instance access to AWS services like S3 and DynamoDB?

To avoid hardcoded credentials, use an IAM instance profile to grant EC2 instances temporary AWS credentials. This allows your applications to access services like S3 and DynamoDB without embedding long-term access keys.

What is the best way to attach an IAM role to an existing EC2 instance?

Attach an IAM role by creating or reusing a least-privilege role, wrapping it in an instance profile, and associating that profile with the EC2 instance. You can then verify credential propagation using the Instance Metadata Service.

How do I verify if my EC2 instance profile is delivering credentials correctly?

Verify EC2 instance profile credentials by querying the Instance Metadata Service Version 2 (IMDSv2). This confirms that temporary AWS credentials are properly propagated to your instance and available for your applications to use.

When do I need to use an IAM instance profile for my EC2 deployment?

Use an IAM instance profile when EC2-based applications require temporary AWS credentials to interact with other services. It is essential for deployment scenarios where applications need secure access to S3, DynamoDB, or CloudWatch without hardcoded keys.

Can I reuse an existing IAM role when setting up my EC2 instance profile?

Yes, the workflow supports creating or reusing an existing IAM role with least-privilege policies. You simply attach the reused role to a new instance profile and then attach that profile to your target EC2 instance.