This course has been replaced with a new course which you can access here: https://cloudacademy.com/course/introduction-aws-codecommit-4189/introduction/
In this course, we’ll provide you with an introduction to AWS CodeCommit and how it can be used to manage your source code. We’ll show you where AWS CodeCommit sits in a CI/CD setup. This lecture will familiarize yourself with the AWS CodeCommit service and ensure you know when and where to use it within your own software projects. We'll then provide a demonstration where we use AWS CodeCommit to deploy and manage source code build for our web portal project.
Source Code
The source code demonstrated within this course can be cloned from the following GitHub repository:
- [Jeremy] In this demonstration, we're gonna use AWS CodeCommit to create a new Git repository. So the first thing we do is we click on the create repository button. This will take us to the next screen. Her we give it a repository name. In this case, we'll call our new repository AWSDevToolsRepo. And for a description, we'll simply say repository for demo. We then click on the create repository button and straightaway we have our repository created. We now have the option to set up SNS topic in which we can then create subscriptions to get e-mail notifications when certain events take place. Here you can see the subscriptions that have been confirmed and unconfirmed. Clicking the manage subscriptions link, I'll add in my e-mail address, jeremy.cook@cloudacademy.com. This will send an e-mail to my account asking me to confirm the subscription. For now, I'll just close that. And in the background, I'll confirm that by going to my e-mail. Next, we get the opportunity to be given some instructions on how we clone our repository. What I'll do here is I'll copy the git clone command and then I'll jump into my terminal. In my terminal, I paste the git clone URL, which we use https to access and clone the repository. Now, as expected, this doesn't work straightaway. And we can see that we got a 403, which indicates a permissions problem. So we'll jump back into IAM and we'll set up our CodeCommit user who doesn't have any policies currently attached. So we'll attach one now. And the policy that we'll attach will be called CodeCommitFullAccess. So we'll just give it full access to CodeCommit. So we're gonna attach this policy to the CodeCommit user. Okay, that's now attached. Okay, clicking on security credentials. Scrolling down, you'll see we have no access keys associated with this user. So we'll jump back into the terminal and rerun the command just to confirm that we should still get an error even though we've attached the policy. So again, as expected, we get the 403. So let's fix this up. We'll jump back into IAM. And this time, we'll create an access key. We'll take the access key and the secret key and we'll configure these back within our terminal. Jumping back into our terminal, we'll update our credentials file and then we'll rerun the clone command. This time we've had success, although we've been given a warning to say that our cloned repository is empty. So now we can jump into the AWS dev tools repo directory and see that, indeed, we have a git repository as per the .git folder. Let's take a quick look at the git config file stored in our home directory. Here we can see how we've got a credential helper setup, which talks out to the AWS CLI using the CACodeCommit profile that we have configured in our AWS config file. Next, we go ahead and populate our empty git folder that we cloned. We'll do a recursive copy from an existing folder that I have on my desktop, which currently contains the static web assets for our web portal. This is the html, JavaScript and CSS files. And a build spec file. Okay, let's copy the build spec file now. This now lists the contents of the directory. We can see we have our app folder and our buildspec.yml file. Performing a git status, we can see that we now need to add these to our next commit. Running the command git add. And we'll just do everything. Now do another git status to see what we've got. And we see that we've added everything. So that looks good. We'll now do a git commit and we'll give it a message initial commit of files. Enter. And that creates our commit. But we still haven't pushed this into our new repository. The final thing we need to do is do a git push, which we'll do now. This pushes the commit to CodeCommit. You can see the progress as it's happening. So that's been pushed up into our repository. If we do a reload within AWS CodeCommit, we now see our new files and folders have been successfully committed into our repository. We can navigate through the folder system. The next thing I'll demonstrate is how to set up a desktop tool to do the code management. In my case, I use GitHub desktop. The particular version I'm using is 1.1.1. And what I need to do here is to add a local repository. Clicking on add a local repository, we navigate to the folder that we cloned out of our CodeCommit repository. We add it. And here you can see the name of it. Now if I click on fetch from origin, I would expect this to fail as the desktop tool can't utilize the AWS CLI mechanism. So what we have to do here is we have to jump back into our IAM and set up or generate https git credentials. So we'll do that and then we'll paste in the username, copy the password, and paste the password in. Clicking the save and retry button we now see that we're fetching again from the origin. And this time, we shouldn't get any errors. Excellent, so that's worked. That's now confirmed that we're authenticating using https credentials. So what I'll do now is I'll jump back into the terminal and I'll fire up Visual Code from within the root directory. And we'll make a quick edit to the build spec file. So clicking on the build spec file, I'm gonna delete one of the commands under the install phase. And we'll save this file. We'll go back to the terminal. We'll do a git status and we can see that we've got one modified file. And I'll jump back into my GitHub desktop tool. I can see that's also detected the change. We'll give it a message for the commit, minor update. Clicking the commit to master button. And then finally pushing it back to origin. And we get an update. And it's completed. So again, everything is in sync. So if I do a git status again from the terminal, again I get a message to say we're all up to date. Heading back to CodeCommit, we'll now click on the commits link and we'll see our new commit. So here, minor update. We can click on the commit ID and CodeCommit will give us this tool that shows us the actual changes made within the file, which is really convenient. One final thing. We'll take a look at settings, notifications. And here we can see we've got one confirmed subscription to our SNS topic. So in the background, I went to my Gmail account and clicked on the confirmation link. Okay, that concludes the CodeCommit demonstration. As you can see it's a very simple service to work with.
Jeremy is a Content Lead Architect and DevOps SME here at Cloud Academy where he specializes in developing DevOps technical training documentation.
He has a strong background in software engineering, and has been coding with various languages, frameworks, and systems for the past 25+ years. In recent times, Jeremy has been focused on DevOps, Cloud (AWS, Azure, GCP), Security, Kubernetes, and Machine Learning.
Jeremy holds professional certifications for AWS, Azure, GCP, Terraform, Kubernetes (CKA, CKAD, CKS).