DevOps and CI/CD are the future of software development. AWS CodeStar makes building a full CI/CD workflow easier and helps us to create a CI/CD toolchain using AWS developer tools – CodeCommit, CodeBuild, and CodePipeline In this blog we will demonstrate how to create CI/CD workflow using AWS CodeStar.
Before beginning to read this blog, it is recommended that you get familiar with DevOps and CI/CD. In earlier blogs, we talked about CI/CD and DevOps. Here are the links to these blogs in case you missed reading them:
In this blog, we will take you through getting a project started and understand the stages of an application’s lifecycle in AWS CodeStar including source code control, build automation, and auto-deployment. Let’s explore!
What is CodeStar?
AWS CodeStar is a cloud-based service that enables you to quickly develop, build, and deploy projects on AWS. An AWS CodeStar project creates and integrates AWS services for your project development toolchain. Depending on your choice of AWS CodeStar project template, that toolchain might include source control, build, deployment, virtual servers or serverless resources, and more.
Benefits of using CodeStar
Develop on AWS in minutes – Easily set up your entire development environment and programming tools for coding, building, testing, and deploying on AWS
- Automatic Provisioning of Resources – When you create a project through CodeStar, AWS will automatically provision a handful of the underlying resources like AWS Elastic Beanstalk, AWS EC2 instances, AWS S3 Buckets, and an AWS CodeCommit repository. One of the most significant resources that CodeStar creates is a continuous delivery pipeline.
- Pre-built Code Templates – CodeStar gives you the option to choose from many pre-built code templates which come with sample code applications. These applications can run on any of the following deployment environments:
- Self-Managed – Amazon EC2 and AWS CodeDeploy
- Managed – AWS Elastic Beanstalk
- Serverless – AWS Lambda
- Options to choose different IDEs – CodeStar gives you three ways of editing code which include AWS Cloud9 IDE, a set of external IDEs like Eclipse or Visual Studio, or CLI.
- Release code faster – You can set up your entire continuous delivery toolchain in minutes
- Support for the many programming languages – You can develop applications using different languages including Python, Java, Ruby, JavaScript, and PHP.
- Team collaboration – Many team members can be added to projects by roles i.e. owners, contributors, etc.
- Integration of issue tracking system – You can integrate JIRA software to manage issues directly from the CodeStar dashboard and monitor application progress and activity
Create a Java Spring web application using CodeStar
Let’s set up and build a CodeStar project using a Java Spring template and will deploy the sample application on AWS Elastic Beanstalk
Login into the AWS console and search for CodeStar service in the services search as shown in the following screenshot:
It will open a CodeStar Dashboard. Click on Create Project button to create a new project as shown in the following screenshot:
We can choose the project template from the given list. As you can see in the following screenshot, there are many templates available to choose from.
As we want to create a Java Spring web application using Elastic Beanstalk as a deployment environment. We will choose a template as shown in the following screenshot. Then click on the Next button.
In this stage, we will set up the project by entering the project name, choosing the repository (here I have chosen CodeCommit), and setting up EC2. You can refer to the following screenshot to understand the project setup. Then click on the Next button.
Now in stage three, let’s review the project. If you need to change anything, click on the previous button, or if everything is ok, click on the Create Project button as shown in the following screenshot:
Once you click on the Create project button, as you can see in the following screenshot, AWS CodeStar is setting up the project resources. It might take a few minutes to create the project (including the repository). After your project has a repository, you can use the Repository page to configure access to it.
As you can see in the above screenshot, in your new project, the navigation bar contains the following pages:
- The Overview page contains information about your project’s activity, project resources, and your project’s README contents.
- The IDE page is where you connect your project to IDE to modify, test and push source code changes. It contains instructions for configuring IDEs for both GitHub and AWS CodeCommit repositories and information about your AWS Cloud9 environments.
- The Repository page displays your repository details, including the name, provider, when it was last modified, and clone URLs. You can also see information about the most recent commit and view and create pull requests.
- The Pipeline page displays CI/CD information about your pipeline. You can view pipeline details such as name, most recent action, and status. You can see the history of the pipeline and release a change.
- The Monitoring page displays either Amazon EC2 or AWS Lambda metrics depending on your project’s configuration.
- The Issues page is for integrating your AWS CodeStar project with a JIRA project. You can configure this to make it possible to track issues from the project dashboard.
In a few minutes, you will see the “Project provisioned” message as shown in the following screenshot. If you notice in the following screenshot, the View Application button is disabled, it will be enabled once the application will deploy successfully, it will take several minutes.
Meanwhile, let’s click on the pipeline tab to see the complete CI/CD pipeline which includes different stages including source, builds, and deployment. As you can see in the following screenshot, the Build process is going on, it might take several minutes.
As you can see in the following screenshot, all stages were completed successfully (Source, Build and Deploy), which means an application is ready and we can view the application.
Click on the Overview tab, and you are able to notice that the View Application tab is enabled once you click on that button, you will be able to see the application outcome.
If you scroll down a little further you will see project activity, where you are able to see the project activity status and dashboard as shown in the above screenshot.
Further below on the same screen, you will see project resources, as shown in the following screenshot. As you can see from the list, lots of resources including IAM roles & policies, Elastic Beanstalk, CodePipeline, CodeBuild, CodeCommit, S3, and CloudFormation have been provisioned to our project by CodeStar. So it’s really an easy way to start a complete CI/CD project using CodeStar!
Let’s check the Elastic Beanstalk deployment environment which has been provisioned by CodeStar for this project. Search it in the search box as shown in the following screenshot:
It will show you the Elastic Beanstalk page where you will be able to see all applications which are already deployed using Elastic Beanstalk. Click on the project which we have created now and it will show the information about application health, running version, platform information (here it is the Tomcat server), and information about all recent events as shown in the following screenshot:
As we experienced that it’s quite easy to create an application using CI/CD workflow in the CodeStar. Now, let’s view the application. Click on the View application button as shown in the following screenshot:
And here we go! As we have chosen the Java Spring web application as a template, we are able to see one default page as the output of our application as shown in the following screenshot.
We can modify this page, add more pages, modify CSS, etc. Let’s quickly do some changes on this page. For this, we can configure either Cloud9 or any Eclipse IDE. In our upcoming blog, we will cover how to configure IDEs in the CodeStar project. Stay tuned!
Right now, we will make a quick change in the message without using any IDE. For this, click on the Repository tab. You will get the repository access as shown in the following screenshot:
To see the complete code of the application, click on the repository named “workfall-webapp”. You will be able to see the complete application structure including folders and files of the application as shown in the following screenshot:
index.jsp page is the welcome page of the application. Let’s modify this page! Open the page by going to the location and clicking on the index.jsp as shown in the following screenshot:
As shown in the following screenshot, we have changed the text in the message. Also added my name, email, and commit message in the commit changes to the master window as shown in the following screenshot:
Once you click on the Commit changes button, it has to start the build and deploy process automatically as we have defined CD/Cd workflow. Let’s check it!
To check it, let’s click on the Pipeline tab. You will see the build and deploy process flow started as shown in the following screenshot:
Meanwhile, let’s see in the Repository tab also. As shown in the following screenshot, we will be able to see the commit which we have done recently.
All set to see the changes! Let’s refresh the application page to see the changes (or, again click on the View application button from the application overview page).
As you can see in the following screenshot, changes that we have made in our application are visible here on the page!
Conclusion
In this blog, you have seen how easily we can create and manage an entire CI/CD pipeline in the application development using the AWS CodeStar and suite of CI/CD services, where a commit or change to code passes through various automated stage gates all the way from building and testing to deploying applications, from development to production environments.
Meanwhile …
Keep Exploring -> Keep Learning -> Keep Mastering
This blog is part of our effort towards building a knowledgeable and kick-ass tech community. At Workfall, we strive to provide the best tech and pay opportunities to AWS-certified talents. If you’re looking to work with global clients, build kick-ass products while making big bucks doing so, give it a shot at workfall.com/partner today.