1 00:00:00,230 --> 00:00:05,460 ‫So a common question I get is how do you manage having multiple AWS accounts? 2 00:00:05,460 --> 00:00:08,830 ‫So for example right now we are in my AWS directory. 3 00:00:09,200 --> 00:00:15,010 ‫And so if we go to config we see there's the default section and then if we go to credentials there's 4 00:00:15,030 --> 00:00:20,460 ‫also the default section which contains an AWS access key id and a secret access. 5 00:00:20,730 --> 00:00:21,690 ‫So how do we do. 6 00:00:21,690 --> 00:00:25,160 ‫Because this links to my one AWS account that I have from before. 7 00:00:25,170 --> 00:00:29,610 ‫But how do we do this if I have multiple AWS accounts? For this 8 00:00:29,610 --> 00:00:34,560 ‫We use something called a profile and so profiles are quite special to use. 9 00:00:34,650 --> 00:00:39,570 ‫Basically what we have to do is define a name for a new profile configure it and then we'll be able 10 00:00:39,570 --> 00:00:41,450 ‫to use it into any command line. 11 00:00:41,460 --> 00:00:45,050 ‫So the way we do it is we type AWS configure. 12 00:00:45,480 --> 00:00:50,940 ‫And this was from before as you can see it prompts me for the access key id that we have right here. 13 00:00:50,970 --> 00:00:54,960 ‫And if I do enter it's going to prompt me for this secret access key that we have right here so fine I'll just 14 00:00:54,960 --> 00:00:56,510 ‫press enter to show you. 15 00:00:56,730 --> 00:01:01,590 ‫So it will change that will do aws configure --profile 16 00:01:01,740 --> 00:01:05,700 ‫And what this does is that we're saying OK we're going to select the profile we want to do. 17 00:01:05,940 --> 00:01:07,770 ‫And so for this we have to name the profile. 18 00:01:07,770 --> 00:01:13,260 ‫I'll call it my other AWS accounts but you can name it whatever you want. 19 00:01:13,260 --> 00:01:15,360 ‫And usually something a little bit short. 20 00:01:15,410 --> 00:01:18,540 ‫Now as you can see the AWS access key id is now None 21 00:01:18,620 --> 00:01:20,040 ‫It used to be something now it's None 22 00:01:20,040 --> 00:01:23,510 ‫So that means that this is an entirely new different account. 23 00:01:23,760 --> 00:01:26,670 ‫So how about I just generate something very quickly. 24 00:01:26,730 --> 00:01:29,400 ‫So I'll just copy random things so for my access key id I'll 25 00:01:29,400 --> 00:01:32,080 ‫Copy this and my secret access key. 26 00:01:32,140 --> 00:01:36,270 ‫Again this is something you would basically obtain on a real AWS account the way we've done it 27 00:01:36,510 --> 00:01:37,110 ‫before. 28 00:01:37,260 --> 00:01:39,890 ‫But right now I'm just pasting some dummy data. 29 00:01:39,960 --> 00:01:40,710 ‫Here we go. 30 00:01:40,860 --> 00:01:44,520 ‫I press enter and for the region name. 31 00:01:44,550 --> 00:01:47,050 ‫I want to do stuff in U.S. West 2 32 00:01:47,250 --> 00:01:50,780 ‫Who knows. The default output format I'll press enter 33 00:01:50,820 --> 00:01:51,400 ‫Here we go. 34 00:01:51,450 --> 00:01:53,400 ‫We have configured an other profile. 35 00:01:53,520 --> 00:01:54,820 ‫So what did change now? 36 00:01:55,020 --> 00:02:01,030 ‫Well if we go to the credentials file now we can see that there is a new brackets. 37 00:02:01,050 --> 00:02:07,680 ‫So before there was just default but now there is my other accounts which contains a new set of credentials. 38 00:02:07,680 --> 00:02:12,180 ‫Similarly if we go to config we now see that for the profile. 39 00:02:12,180 --> 00:02:15,930 ‫My other aws accounts here is the region we're going to use. 40 00:02:16,190 --> 00:02:20,540 ‫And so this is something that's quite cool because now we can switch between different accounts. 41 00:02:20,580 --> 00:02:26,450 ‫Now if you do it AWS s3 ls this is going to execute against the default profile. 42 00:02:26,540 --> 00:02:27,190 ‫OK. 43 00:02:27,240 --> 00:02:29,350 ‫Because this is how we configured it. 44 00:02:29,520 --> 00:02:35,460 ‫But if you want to execute this function against another profile say my other aws account that we just configured 45 00:02:35,880 --> 00:02:39,970 ‫we have to add --profile and the name of the profile we have. 46 00:02:39,970 --> 00:02:41,680 ‫So it's just a little trick you should know about. 47 00:02:41,790 --> 00:02:46,140 ‫But basically for any commands you can use --profile as well as the profile name you want 48 00:02:46,470 --> 00:02:51,030 ‫as long as you can configure that profile beforehand using the aws configure command line. 49 00:02:51,030 --> 00:02:53,910 ‫So that's it, it's not something you should know for the exam but it's something you should know as a 50 00:02:53,910 --> 00:02:56,040 ‫developer and I'd like to give you real world tips. 51 00:02:56,190 --> 00:03:02,250 ‫So if you start having multiple AWS accounts make sure to use profiles and to set your command line to use 52 00:03:02,250 --> 00:03:07,050 ‫the --profile command line arguments to target the right AWS accounts.