AWS Cloud Architecture•Part 5: Security, IAM, Messaging & Enterprise Deployments (51 - 65)
IAM Instance Profiles.
In Simple Words: A container that attaches an IAM Role directly to an EC2 instance. The application retrieves temporary short-lived credentials via the Instance Metadata Service (IMDSv2), eliminating the security risk of hardcoding static access keys in code or config files.
bash
# Retrieving temporary IMDSv2 role credentials inside EC2:
TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"`
curl -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/iam/security-credentials/AppRole