Tutorial Highlights & Transcript
00:00 - Intro
00:53 - Problems
03:01 - Solutions
The first step is to set the pipeline source as GitHub. It supports two versions. Recently, GitHub and AWS introduced a new setup version, version two, which supports this CodeStar connection. For the CodeBuild project, the CodeBuild source will not be GitHub, but its source will be directly AWS CodePipeline because CodePipeline will be the one who will provide the source in GitHub to CodeBuild as an artifact. This solution will not create any webhook. It will just use a single point of source for the image changes. Point of source, which will be directly associated with our GitHub repository using CodeStar connection.
05:34 - Solution Diagram
07:07 - Connecting GitHub to AWS CodeBuild using AWS CodeStar
09:09 - Setting up AWS CodePipeline
Let’s go to the CodePipeline. Here, you can see the pipeline yasir-test. If we just open it, you can see the source is GitHub version two, and the build is AWS CodeBuild, which I just showed you earlier in the build console. That’s why it is trying the source provider as CodePipeline. If we just try to edit it and edit the source stage. You see the action provider is GitHub version two. Here, we have just provided the error for the CodeStar connection. It will just prompt you that your GitHub connection is ready to use. Here we have defined the demo repo, actually, we haven’t defined it, the CodeStar connection automatically filled it for us. But I use the branch name here because I was not handling the branch name in the CodeStar connection because it’s convenient for us to change the branch name whenever we want. Start the pipeline on source code change. By checking this option, it will automatically trigger the CodePipeline for us when there is an event change, or when a user or someone will try to push something and it will automatically trigger the CodePipeline for us. So other just basic options. Let’s try to trigger this. I’ll be committing a test commit here. Okay, the commit is done. If I just hit refresh, you can see that the pipeline has been triggered, and it’s in progress. It has checked out the GitHub repository and it has triggered the CodeBuild. Let’s double-check to see if AWS created an extra webhook for us. No, this was the old one, but it has not created the webhook for us. Using this AWS CodeStar connection with an integrated GitHub application, you can create many AWS CodeBuild projects with CodePipeline without any limitation of using webhooks. Of course, it will be using a webhook in the back end, but it’s not managed by us. It’s strictly managed by AWS. It has created and scoped the legacy webhooks, which is this one. Once these webhooks reach the number 20, it will complain “please remove any stale webbooks from the GitHub console and try again.” But using this email, it will make your life easier for introducing new CodeBuild projects for different branches or different applications.
And you see it has successfully built a build project so nothing was blocking it from triggering it. That was a quick demo for this solution that I presented to one of my clients so I thought to share it with you guys.
Yasir is a DevOps Support Engineer at nClouds. He has multiple technical certifications including AWS Certified Solutions Architect - Associate and Certified Kubernetes Administrator.