- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Cloud
- Security
Using EC2 Roles and Instance Profiles in AWS
If you are still hardcoding AWS access keys in your EC2 applications, there's a **better** way—and it takes less than 30 minutes to master. This hands-on lab shows you how to use EC2 instance profiles to grant your servers secure access to AWS services like S3 without ever touching static credentials.
Lab Info
Table of Contents
-
Challenge
Upload a File to the Amazon S3 bucket and Copy the Bucket ARN
Choose any file you have locally, or you can optionally download the lab diagram locally, and upload it to the provided Amazon S3 bucket in you AWS account. Be sure to also copy the S3 bucket ARN for later on.
-
Challenge
Connect to the Old EC2 and Locate the Hardcoded Credentials
Leverage Session Manager to connect to the
Old ServerAmazon EC2 instance and locate the hardcoded set of AWS secret access key credentials forssm-user. There should be an access key pair, as well as a configuration for output and Region. -
Challenge
Create the Managed Permissions Policy
Create a new permission policy with the following information:
- Name: allow-ec2-to-app-bucket
- Permissions: List buckets and get objects from the S3 bucket that was created for you (Should be named like c6e0-account_id-app-bucket)
-
Challenge
Create the IAM Role and Attach Permissions
Create a brand-new IAM role with the following information:
- Name:
ec2-to-s3-role - Description: Whatever you want!
- Trusted entity type:
Amazon EC2 - Permissions: Attach the
allow-ec2-to-app-bucketpolicy you created, and attach theAmazonSSMManagedInstanceCoreAWS managed policy
- Name:
-
Challenge
Attach the IAM Role to the New EC2 Instance
Take the newly created
ec2-to-s3-roleIAM role and attach it to yourNew ServerEC2 instance. -
Challenge
Get the File From Amazon S3 on the New EC2 Instance
Connect to the
New SeverAmazon EC2 instance via session manager. Use the AWS CLI to get the recently uploaded file from your Amazon S3 bucket and save it to the/tmpdirectory.
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.