How To Set Up Profiles To Manage AWS From The Command Line Using AWS CLI And PowerShell

With AWS, you can create multiple configurations for authentication. This is useful for people (like Bryce) who need to have a profile for internal work projects, a few profiles for client projects, and a profile for personal projects. Using the AWS CLI and PowerShell, we’ll show you how to create these profiles with built in commands like “aws configure” and “New-AWSCredential” to then call later in your scripts. You’ll also get to see how to call these profiles and look at them from the credential and config files on your local machine, as well as with the “Get-AWSCredential” PowerShell cmdlet.

In this snip you'll learn how to create multiple AWS credential profiles and be able to manage those. The first thing that we need to do whenever we talk about managing AWS credentials is figure out where those are with PowerShell. We can use the get AWS credential. Commandlet followed by the list profile detailed parameter. In order to find all of our profiles that we have configured on our machine. In addition, we can also have in the home directory or in the user profile directory in windows. The AWS hidden folder within there. We have a config and credentials file which also has data inside. We can use the get content commandlet on the config and credentials file in order to view the details inside. For instance, if I use it on my credentials file we can see that I have my access key and my secret key there. Within the config file we will see the output format as well as the available regions to us. If we want to create a new key using PowerShell what we need to do is first set an access key and secret key variable. Will want to set these equal to the access and secret key that is generated by the AWS Management Console? Once we have those keys will then use the set AWS credentials. Commandlet calling those access key and secret keys. And then will use the store as parameter to make a name for our new profile in my case, I'll call it techsnips. Let's go ahead and create that now. Once created we can use our list profile detail commandlet again in order to see everything that we have available. And as we can see techsnips is there for us. If we want to configure new profiles with the AWS Command line interface. We can use the AWS configure command. This by default will just set our default credentials. If we use the AWS configure dash dash profile command. We can then name, a new profile in order to configure AWS. What's go ahead and do that? Now I'll call this new profile free tier to be my free tiers credentials. Once this runs will need to input our access key. As well as our secret key. When entered we can enter a default region name. I have mine set to us W 2. And we can have a default output format. I have mind set to JSON. Once we have run that command, we can use the get AWS credential list profile detail. Commandlet again in order to see that we now have our free tier profile enabled. If we want to remove a profile. We simply need to call the remove AWS credential profile. Commandlet followed by the profile name. I'll go ahead and clean up my techsnips demo now. Once you use the commandlet it will ask you to confirm that this is what you would like to do. And again we can use that get AWS credential command line in order to see that our techsnips profile is no longer there. Thanks for watching.