1 00:00:00,630 --> 00:00:03,090 ‫So let's practice using code artifacts. 2 00:00:03,090 --> 00:00:05,520 ‫So to do so, I'm going to create a repository 3 00:00:05,520 --> 00:00:09,330 ‫and I'll call this one Demo Repository. 4 00:00:09,330 --> 00:00:11,490 ‫And optionally, we can select an upstream. 5 00:00:11,490 --> 00:00:14,520 ‫So we want to pull packages from Python. 6 00:00:14,520 --> 00:00:17,310 ‫So I will use this Python store. 7 00:00:17,310 --> 00:00:18,840 ‫So I will click on next. 8 00:00:18,840 --> 00:00:21,150 ‫And next we need to define a domain. 9 00:00:21,150 --> 00:00:25,230 ‫So domain is where do we want to store the artifact data? 10 00:00:25,230 --> 00:00:28,290 ‫All the repos, all the the packages data. 11 00:00:28,290 --> 00:00:30,360 ‫So we choose our accounts 12 00:00:30,360 --> 00:00:32,670 ‫and as you can see there's no domain in our accounts. 13 00:00:32,670 --> 00:00:35,340 ‫And so therefore we need to create a domain. 14 00:00:35,340 --> 00:00:37,140 ‫And this domain represents your company. 15 00:00:37,140 --> 00:00:40,290 ‫So I want to name it, my-company. 16 00:00:40,290 --> 00:00:41,400 ‫Additionally, for the domain 17 00:00:41,400 --> 00:00:43,020 ‫where all the packages are going to be stored 18 00:00:43,020 --> 00:00:45,810 ‫you need to specify a KMS key for encryption 19 00:00:45,810 --> 00:00:49,320 ‫and I will just simply use the AWS managed key for this. 20 00:00:49,320 --> 00:00:50,310 ‫I'll click on next. 21 00:00:50,310 --> 00:00:52,980 ‫And as you can see what is being created now out of it 22 00:00:52,980 --> 00:00:55,500 ‫is my demo repository, 23 00:00:55,500 --> 00:00:58,082 ‫which will have one upstream repository called 24 00:00:58,082 --> 00:01:00,210 ‫this pypi-store. 25 00:01:00,210 --> 00:01:01,590 ‫And then out of it 26 00:01:01,590 --> 00:01:04,740 ‫this upstream repository has one external connection 27 00:01:04,740 --> 00:01:07,020 ‫to the public pypi store. 28 00:01:07,020 --> 00:01:11,493 ‫Okay, so we're going to now create this repository. 29 00:01:12,870 --> 00:01:14,010 ‫And if you go one level up 30 00:01:14,010 --> 00:01:16,230 ‫now we see two repositories in here. 31 00:01:16,230 --> 00:01:18,990 ‫We have the one that has an external connection 32 00:01:18,990 --> 00:01:19,920 ‫which is the pypi store. 33 00:01:19,920 --> 00:01:23,160 ‫It says here connected to a public repository. 34 00:01:23,160 --> 00:01:26,130 ‫And then we have the demo repository that we have. 35 00:01:26,130 --> 00:01:26,963 ‫Okay? 36 00:01:26,963 --> 00:01:29,340 ‫As we can see, we have the pypi store 37 00:01:29,340 --> 00:01:30,720 ‫as an upstream repo, 38 00:01:30,720 --> 00:01:31,710 ‫and we could, for example 39 00:01:31,710 --> 00:01:33,360 ‫edit the upstream repositories 40 00:01:33,360 --> 00:01:36,030 ‫and add multiple ones if we wanted to. 41 00:01:36,030 --> 00:01:37,710 ‫Okay. But how do we actually now 42 00:01:37,710 --> 00:01:40,500 ‫leverage this demo repository. 43 00:01:40,500 --> 00:01:43,260 ‫For this, we need to view the connection instruction, 44 00:01:43,260 --> 00:01:46,830 ‫but let's go and open CloudShell in another tab 45 00:01:46,830 --> 00:01:48,510 ‫because this is where we're going to be running 46 00:01:48,510 --> 00:01:49,650 ‫our commands. 47 00:01:49,650 --> 00:01:52,020 ‫So let's clear this. 48 00:01:52,020 --> 00:01:54,660 ‫Okay, now let's go back into code artifact 49 00:01:54,660 --> 00:01:56,700 ‫and view the connection instruction. 50 00:01:56,700 --> 00:01:58,950 ‫We're going to use pip 51 00:01:58,950 --> 00:02:00,630 ‫and we have two ways of doing it. 52 00:02:00,630 --> 00:02:02,010 ‫The first one is that 53 00:02:02,010 --> 00:02:05,760 ‫you can just use the CLI to configure pip for you. 54 00:02:05,760 --> 00:02:07,320 ‫And if you try to run this command, 55 00:02:07,320 --> 00:02:08,153 ‫I will show you right now 56 00:02:08,153 --> 00:02:10,590 ‫I'll copy it and I will paste it in CloudShell. 57 00:02:10,590 --> 00:02:14,670 ‫Because of a CloudShell bug or a code artifact bug, 58 00:02:14,670 --> 00:02:16,170 ‫I'm not really sure which one it is 59 00:02:16,170 --> 00:02:18,090 ‫but it says pip is not found. 60 00:02:18,090 --> 00:02:20,520 ‫That's because actually pip3 is installed, 61 00:02:20,520 --> 00:02:21,660 ‫but not pip. 62 00:02:21,660 --> 00:02:24,120 ‫And this is just code artifact not 63 00:02:24,120 --> 00:02:26,160 ‫being good at using pip3 64 00:02:26,160 --> 00:02:28,320 ‫or CloudShell not installing pip, 65 00:02:28,320 --> 00:02:29,220 ‫whichever it is. 66 00:02:29,220 --> 00:02:31,200 ‫But this does not work for now. 67 00:02:31,200 --> 00:02:33,330 ‫So what I'm going to do is the manual setup, which is good 68 00:02:33,330 --> 00:02:37,050 ‫because we'll see as well how to manually set up this. 69 00:02:37,050 --> 00:02:39,750 ‫So the first thing we have to do is to use code artifact 70 00:02:39,750 --> 00:02:42,090 ‫to get an authorization token 71 00:02:42,090 --> 00:02:44,430 ‫which is going to be authenticated to my domain, 72 00:02:44,430 --> 00:02:46,290 ‫my domain owner, my region. 73 00:02:46,290 --> 00:02:48,810 ‫And the idea is that we'll be able using this token 74 00:02:48,810 --> 00:02:50,850 ‫to connect pip to it. 75 00:02:50,850 --> 00:02:53,010 ‫So we'll export this 76 00:02:53,010 --> 00:02:54,210 ‫and then if I do echo 77 00:02:54,210 --> 00:02:57,480 ‫and then the actual code artifact token 78 00:02:57,480 --> 00:02:59,730 ‫I can see this token has been generated. 79 00:02:59,730 --> 00:03:01,350 ‫Now it's valid for 12 hours 80 00:03:01,350 --> 00:03:02,970 ‫and after 12 hours it will have expired 81 00:03:02,970 --> 00:03:04,237 ‫and I won't be able to connect 82 00:03:04,237 --> 00:03:08,700 ‫to pip to my repository on code artifact 83 00:03:08,700 --> 00:03:11,340 ‫therefore, we'll have to rerun this command. 84 00:03:11,340 --> 00:03:15,540 ‫Now we can just run this pip conflict command 85 00:03:15,540 --> 00:03:18,810 ‫which will not work until you actually modify the beginning 86 00:03:18,810 --> 00:03:21,540 ‫of the command and use pip3. 87 00:03:21,540 --> 00:03:23,790 ‫So we have pip3 config set, 88 00:03:23,790 --> 00:03:25,500 ‫and now we are connecting 89 00:03:25,500 --> 00:03:29,160 ‫to our code artifact repo automatically. 90 00:03:29,160 --> 00:03:31,740 ‫So now if I do pip, install 91 00:03:31,740 --> 00:03:34,230 ‫and response which is the name of a package, 92 00:03:34,230 --> 00:03:35,400 ‫and press enter, 93 00:03:35,400 --> 00:03:38,940 ‫and actually I do need to do pip3 install response. 94 00:03:38,940 --> 00:03:41,621 ‫This is actually going to connect to code artifact 95 00:03:41,621 --> 00:03:46,470 ‫and it's going to pull this response dependency from it. 96 00:03:46,470 --> 00:03:49,290 ‫And of course, if this package depends on other things 97 00:03:49,290 --> 00:03:51,090 ‫then it's going to download the rest as well 98 00:03:51,090 --> 00:03:53,790 ‫which is why you see a lot of information in here. 99 00:03:53,790 --> 00:03:57,450 ‫So now it's being installed and we're done very soon. 100 00:03:57,450 --> 00:04:00,600 ‫And what we see now is that if you go to code artifacts, 101 00:04:00,600 --> 00:04:03,630 ‫and then you refresh your packages, now you see 102 00:04:03,630 --> 00:04:05,550 ‫as you can see all the packages that were pulled. 103 00:04:05,550 --> 00:04:07,440 ‫So we have the response package 104 00:04:07,440 --> 00:04:11,340 ‫but also any other package that response was depending upon. 105 00:04:11,340 --> 00:04:14,880 ‫And this is inserted into my demo repository, 106 00:04:14,880 --> 00:04:16,830 ‫but if I go into my other repo 107 00:04:16,830 --> 00:04:18,390 ‫that has an external connection, 108 00:04:18,390 --> 00:04:20,550 ‫as you can see, they're there as well. 109 00:04:20,550 --> 00:04:22,135 ‫So because we keep one copy 110 00:04:22,135 --> 00:04:24,690 ‫on the repo that has an external connection, 111 00:04:24,690 --> 00:04:26,940 ‫and one copy on the repo that we connected to 112 00:04:26,940 --> 00:04:29,430 ‫which is the demo repository. 113 00:04:29,430 --> 00:04:31,020 ‫So if now if I click on response, 114 00:04:31,020 --> 00:04:35,220 ‫I can see have version 0.5.0 which is the latest 115 00:04:35,220 --> 00:04:38,520 ‫but I can for example, try to install another version. 116 00:04:38,520 --> 00:04:41,850 ‫So I do == 0.4.0, 117 00:04:41,850 --> 00:04:43,110 ‫and this is going to install 118 00:04:43,110 --> 00:04:45,690 ‫a previous version of this package. 119 00:04:45,690 --> 00:04:48,300 ‫And I go back to code artifact, I refresh this page 120 00:04:48,300 --> 00:04:49,560 ‫and this can take a bit of time. 121 00:04:49,560 --> 00:04:51,540 ‫Sometimes you have to wait 30 seconds, 122 00:04:51,540 --> 00:04:52,590 ‫as you can see now 123 00:04:52,590 --> 00:04:56,460 ‫I have version 0.5.0, and version 0.4.0 124 00:04:56,460 --> 00:04:58,950 ‫now available within my demo repository 125 00:04:58,950 --> 00:05:00,450 ‫which is pretty cool. 126 00:05:00,450 --> 00:05:02,610 ‫So other things I want to show you is, for example 127 00:05:02,610 --> 00:05:04,950 ‫around repository policy. 128 00:05:04,950 --> 00:05:08,760 ‫So you can apply a repo policy at the repo level, 129 00:05:08,760 --> 00:05:11,520 ‫and here we have the read-only access 130 00:05:11,520 --> 00:05:13,320 ‫read and publish access or full access 131 00:05:13,320 --> 00:05:15,540 ‫and we can choose the type of governance we want 132 00:05:15,540 --> 00:05:17,220 ‫which will edit the policy, 133 00:05:17,220 --> 00:05:21,330 ‫and then we can simply paste it in here to determine access. 134 00:05:21,330 --> 00:05:24,810 ‫Other things I can do is go to my domain, 135 00:05:24,810 --> 00:05:25,643 ‫click on it. 136 00:05:25,643 --> 00:05:29,010 ‫As you can see, my company has two repos, 137 00:05:29,010 --> 00:05:32,400 ‫but what I can do is I can apply a domain policy, 138 00:05:32,400 --> 00:05:35,010 ‫and again here the example policies 139 00:05:35,010 --> 00:05:36,540 ‫for contributor domain access 140 00:05:36,540 --> 00:05:38,970 ‫or full domain access for an IAM principle 141 00:05:38,970 --> 00:05:40,530 ‫or an organization. 142 00:05:40,530 --> 00:05:42,270 ‫So this is very handy 143 00:05:42,270 --> 00:05:44,880 ‫and we've basically seen how cloud artifact works. 144 00:05:44,880 --> 00:05:48,000 ‫Now you can go ahead and create more repositories 145 00:05:48,000 --> 00:05:51,000 ‫and then define which ones are the upstream of which, 146 00:05:51,000 --> 00:05:53,880 ‫and then configure for example, Python pip 147 00:05:53,880 --> 00:05:55,050 ‫to pull from them. 148 00:05:55,050 --> 00:05:56,220 ‫And automatically, as you can see, 149 00:05:56,220 --> 00:05:59,250 ‫dependencies will be stored in our repositories. 150 00:05:59,250 --> 00:06:00,083 ‫So that's it. 151 00:06:00,083 --> 00:06:01,740 ‫Now to just finish this hands on 152 00:06:01,740 --> 00:06:05,103 ‫just take this repo and you delete it. 153 00:06:06,900 --> 00:06:10,053 ‫You take the second repo and you delete it as well. 154 00:06:11,190 --> 00:06:13,470 ‫And next, you take your domain 155 00:06:13,470 --> 00:06:17,280 ‫and you can simply delete it and you're good to go. 156 00:06:17,280 --> 00:06:18,780 ‫Okay, that's it for this lecture. 157 00:06:18,780 --> 00:06:20,040 ‫I hope you liked it 158 00:06:20,040 --> 00:06:22,083 ‫and I will see you in the next lecture.