Ravi Sir's Cards › AWS
Attach role to EC2
This revision card explains Attach role to EC2. It starts from the need that putting AKIA keys on the instance is how keys leak into GitHub. It describes create an EC2 instance profile/role with your S3 read policy; attach to the instance; use the instance metadata credentials automatically via AWS CLI. The how-to section notes IAM role trusted by ec2.amazonaws.com , then attach policy , then Modify IAM role on the instance (or launch with it). An example on the card is on the instance: aws s3 cp s3://lab-bucket/hi.txt - works with no keys configured.
Read card text
What this card says
Why do we need it?
Putting AKIA keys on the instance is how keys leak into GitHub.
What is it?
Create an EC2 instance profile/role with your S3 read policy; attach to the instance; use the instance metadata credentials automatically via AWS CLI.
instance profile
How to do it
IAM role trusted by ec2.amazonaws.com → attach policy → Modify IAM role on the instance (or launch with it).
Example
On the instance: aws s3 cp s3://lab-bucket/hi.txt - works with no keys configured.