image
Managing Profiles
Start course
Difficulty
Beginner
Duration
32m
Students
114
Ratings
5/5
Description

This course introduces you to the AWS Command Line Interface. 

Learning Objectives

  • Install and configure the AWS Command Line Interface
  • Manage CLI credential profiles
  • Structure CLI commands
  • Better control the outputted response data
  • Use input functionality to make working with the CLI easier  

Intended Audience

  • Those looking to get more familiar with the AWS Command Line Interface

Prerequisites 

Transcript

When you type in aws configure for the first time, and set your access keys, your region, and output, you’re specifying the configurations for your default profile. This means that for every command you run, it will fall back on this default profile unless you specify a different profile.

Each profile you create can have different credentials associated with them. This is helpful in case your default credentials limit access to certain services or operations. You can then use a different profile with different credentials to perform those actions. 

You can create profiles in several different ways. The first way is by running the command aws configure –profile and then provide a profile name. For example, S3User. 

It will then ask for credentials, region, and output. I’ll paste in the access key, and then the secret access key. 

Next, I’ll choose the region I work out of. For example, I’ll choose us-east-1. And then my preferred output, say JSON. And I’ve successfully created a profile called S3User.  

if you don’t want to copy and paste your access keys, you can choose to import them via a CSV file. This is helpful if you want to import a lot of credentials at one time. I’ll show you an example of one of these files. Here I have a file that specifies the name of the profile as the User Name. In this case, I’m calling the profile EC2User.  And then I also specify values for my access key and my secret access key, all separated by commas. 

Back in the terminal, I can run the command aws configure import —csv and then specify the file by using file://Downloads/ec2user_credentials.csv. This will then import the profile. 

To verify that you’ve created the profiles successfully, you can run the command aws configure list-profiles, which shows both my S3User profile and the EC2User profile that I imported from the CSV file. 

If I wanted to see all of the credentials for each of my profiles, I can use the command‘cat ~/.aws/credentials’. Here it shows the access keys for not only my default profile, but also my S3User profile, and the EC2User profile as well. 

Now let’s actually use one of these profiles. For example, let’s say I want to list all of my S3 buckets, and I know my S3User has permissions to do that. First, I’ll run the command to list all my buckets, which is aws s3 ls. Notice that if I don’t specify a profile, it falls back to using the credentials for my default profile which does not have permission to list s3 buckets, so the command fails. 

To get around this, I’ll need to attach the –profile parameter and provide the name of my profile which is called S3User. Let’s go ahead and do that. 

Now, this uses the credentials for my S3User profile to run this command instead of my default profile. And in this case, you can see the command has succeeded, and I get a list of my s3 buckets back. 

If I didn’t want to keep using the –profile parameter on every command, I could use an environment variable to set the profile. By using the command ‘export AWS_PROFILE=S3User’, I can set the profile for my shell session. That way, I can list buckets, create a bucket, and then delete the bucket all without specifying the –profile parameter. 

That’s all for this one - I’ll see you next time! 

About the Author
Students
2970
Courses
27
Learning Paths
5

Alana Layton is an experienced technical trainer, technical content developer, and cloud engineer living out of Seattle, Washington. Her career has included teaching about AWS all over the world, creating AWS content that is fun, and working in consulting. She currently holds six AWS certifications. Outside of Cloud Academy, you can find her testing her knowledge in bar trivia, reading, or training for a marathon.